Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Not being positioned in floor?

local floorRay = Ray.new(Torso.Position, (Torso.Position - Vector3.new(0, 200, 0)).unit * 200)
local floorHit, floorPos = workspace:FindPartOnRay(floorRay, Character)
		
if floorHit then
	Figure.Position = floorPos
	local random = CFrame.new(floorPos) * CFrame.new((math.random() * 2-1) * 9, ,(math.random() * 2-1) * 9)
	Figure.CFrame = random		
end

I've tried doing this but it seems to float in air rather than just being in the nearest floor when not in ground, I need help because this ain't working

1 answer

If you want it to be positioned inside the floor, you need to replace CFrame.new(floorPos) with CFrame.new(floorHit.Position), as floorPos is the point of the collision, not the part the ray found. Also, the Figure.Position = floorPos is probably unnecessary.

1 comment

0

Still didn't work, what I'm trying to do is position a part in a random radius relative to the torso on the floor if you're above ground

This discussion is preserved as it was. New answers, comments, and votes are closed.