How do I fix my Floating Horse problem?
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.
01 | local HOOF = script.Parent |
02 | local BP = HOOF.BodyPosition |
03 | local VS = HOOF.Parent.VehicleSeat |
04 | GRASS = game.Workspace.Land.Grass |
07 | function inRange(part 1 , part 2 , range) |
08 | return (part 1. Position - part 2. Position).magnitude < = range |
14 | if VS and inRange(Workspace.Horse.VehicleSeat, Workspace.Land.Grass, 5 ) then |
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!