Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I slowly lower a brick to the nearest ground w/Raycasting?

Asked by 8 years ago

I am trying to lower a brick to the ground using raycasting

This is what I have...

cframe = script.Parent.CFrame

local ray = Ray.new(cframe.p, (Vector3.new(cframe.x, -100, cframe.z) - cframe.p).unit*300)
local hit, position = game.Workspace:FindPartOnRay(ray, script.Parent)

repeat
    print("works")
    script.Parent.Position = Vector3.new(cframe.x, cframe.y -1 , cframe.z)
wait(.5)
until cframe == position

This is inserted in a normal part in workspace, hovering above the ground. I'm getting the "works" message, but its not budging. Any help?

0
Changed line 8 to script.Parent.Position = script.Parent.Position - Vector3.new(0,1,0), but now it infinitely loops randomsmileyface 375 — 8y

Answer this question