Im trying to make it so when a player drives a boat, if they hit land, itll teleport the boat back 10 or so studs so that there not “driving” on land, but its not working at all, any help?
local player = nil
script.Parent:GetPropertyChangedSignal("Occupant"):Connect(function()
if script.Parent.Occupant then
player = Players:GetPlayerFromCharacter(script.Parent.Occupant.Parent)
else
if not script.Parent.Occupant then
player = nil
end
end
end)
function checkwater()
for i,v in pairs(script.Parent.Parent.WaterTouch:GetTouchingParts()) do
print(v)
if v.Name == "Wooter" then
onwater = true
print("on water true")
else
if v.Name == "Sand Dune" then
onwater = false
local direction = player.Character:FindFirstChild("HumanoidRootPart").CFrame + layer.Character:FindFirstChild("HumanoidRootPart").CFrame.LookVector - 5
script.Parent.CFrame = direction
print("on water false")
end
end
end
end