I’m having issues with my part hovering above the ground
local Part = script.Parent
local Body = script.Parent.BodyPosition
local CarBody = workspace.Part
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {}
raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
raycastParams.IgnoreWater = false
local RunService = game:GetService("RunService")
function Run()
local R = Ray.new(Part.Position, Vector3.new(0,-4,0))
local PartFound, Pos = workspace:FindPartOnRay(R)
local DistanceToGround = Part.Position.Y-Pos.Y
local Var = CarBody.Size.X * CarBody.Size.Z * 500
Body.Position = Vector3.new(Part.Position.X, DistanceToGround, Part.Position.Z)
Body.MaxForce = Vector3.new(Var, Var, Var)
print(DistanceToGround)
--print(Pos.Y)
--print(Body.MaxForce)
--print(Body.Position)
end
RunService.Stepped:Connect(Run)
What happens is this :
What I’m trying to do is make the part hover a X amount of studs above the ground all the time
Like this :
I’ve tried many things all day long and couldn’t find my answer.
Thanks for any help in advance!