Advertisement
lafur

Untitled

Jul 10th, 2020
1,121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local man = workspace.lafur2
  2. local root = man.HumanoidRootPart
  3. local viewp = Instance.new("Part",man)
  4. viewp.Material = "Neon"
  5.  
  6. for i = 1,30*15 do
  7.     local normal,hitp do
  8.         local ray = Ray.new(root.Position,root.CFrame.upVector * -40)
  9.         local _,hitpos,norm = workspace:FindPartOnRay(ray,man)
  10.         normal = norm
  11.         hitp = hitpos
  12.     end
  13.    
  14.     -- the character's upvector will be the normal
  15.     -- the character's lookvector will stay the same
  16.     -- the character's rightvector will be upvector:cross(normal)
  17.     local upvec = normal
  18.     local lookvec = root.CFrame.lookVector
  19.     local rightvec = normal:Cross(lookvec)
  20.  
  21.     -- construct a new cframe from the right, up, & lookvectors
  22.     local trgcf = CFrame.fromMatrix(root.Position, rightvec,upvec,lookvec)
  23.     viewp.CFrame = (trgcf-trgcf.p) + hitp + normal*.5
  24.     -- convert it to object space, so it can be used in C1
  25.     local nu_cf = root.CFrame:ToObjectSpace(trgcf)
  26.    
  27.     -- C0 needs to be reset first!!!
  28.     root.RootJoint.C0 = CFrame.new()
  29.     -- now, set C1 & see what happens
  30.     root.RootJoint.C1 = nu_cf
  31.     wait()
  32. end
  33.  
  34. viewp:Destroy()
  35. print("ended")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement