Hey guys, I'm pretty new to scripting, and i've been working on this one problem for hours, and i feel like I'm close to a solution but i just can't figure it out on my own. I'm not looking for a completed script, just maybe a suggested function or functions to use or something.
So I have a ride-able horse that works basically the same as a hovercraft, it hovers and basically glides along the ground to move. The problem is there is water in my game and I don't want the horse to be able to float above the water. I have been trying to figure out how to make the horse fall when it isn't above land, but the only things i could think of were things that had to do with range, like if the horse was a certain distance away from land it would remove the seat which would make the horse fall theoretically. I came up with this, but it doesn't work.
local HOOF = script.Parent local BP = HOOF.BodyPosition local VS = HOOF.Parent.VehicleSeat GRASS = game.Workspace.Land.Grass function inRange(part1, part2, range) return (part1.Position - part2.Position).magnitude <= range end while wait(0.5) do if VS and inRange(Workspace.Horse.VehicleSeat, Workspace.Land.Grass, 5) then VS:remove() end
I realize if this script worked it would do the opposite and actually remove the seat if it IS in range, but if i could get it to work like this i can just flip it to make it happen when out of range.
Thanks so much for any and all help! You guys rock!