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?

1 comment

0

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