Hi developers,
I am trying to make a floating vehicle but the way I’m doing it doesn’t seem efficient and as you can see it’s not smooth and it’s keep going up and down, I’ve searched for tutorials but I can’t find a proper way to do it.
Do you have any suggestions on how I can make that possible?
Thank you.
The script I used:
local part = script.Parent
local seat = script.Parent.Parent.VehicleSeat
local rayToGround = Ray.new(part.Position, Vector3.new(0,-10,0))
local testpart = Instance.new("Part", workspace)
testpart.Name = "testPart"
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if seat.Occupant ~= nil then
while wait(0.05) do
local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(rayToGround, {part})
if hit then
local rayDistanceToGround = part.Position.Y - position.Y
print(rayDistanceToGround)
if rayDistanceToGround < 1 then
part.Velocity = Vector3.new(0,9,0)
end
end
end
end
end)
Here is the result: