i I have a boat script, this script makes the boat work, “walk”, turn left and right, etc. How do I get the boat to stop when the player leaves the boat seat?
My script:
local sail1 = script.Parent.Parent.sail1-- 3.53, 29.993, 46.548
local sail11 = script.Parent.Parent.sail11 --5.659, 21.105, 36.259
local sail2 = script.Parent.Parent.sail2 --2.076, 17.643, 25.597
local sail22 = script.Parent.Parent.sail22 --2.076, 15.162, 23.597
local sail3 = script.Parent.Parent.sail3 --5.659, 17.68, 24.859
local tweenService = game:GetService("TweenService")
local Properties1 = {
Size = Vector3.new(3.53, 29.993, 46.548)
}
local Properties11 = {
Size = Vector3.new(5.659, 21.105, 36.259)
}
local Properties2 = {
Size = Vector3.new(2.076, 17.643, 25.597)
}
local Properties22 = {
Size = Vector3.new(2.076, 15.162, 23.597)
}
local Properties3 = {
Size = Vector3.new(5.659, 17.68, 24.859)
}
----------------------------
local PropertiesOld1 = {
Size = Vector3.new(1.286, 29.993, 46.548)
}
local PropertiesOld11 = {
Size = Vector3.new(0.694, 21.105, 36.259)
}
local PropertiesOld2 = {
Size = Vector3.new(1.054, 17.643, 25.597)
}
local PropertiesOld22 = {
Size = Vector3.new(1.07, 15.162, 23.597)
}
local PropertiesOld3 = {
Size = Vector3.new(0.923, 17.68, 24.859)
}
local tweenInfoo1 = TweenInfo.new(0.4, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local tween1 = tweenService:Create(sail1, tweenInfoo1, Properties1)
local tween11 = tweenService:Create(sail11, tweenInfoo1, Properties11)
local tween2 = tweenService:Create(sail2, tweenInfoo1, Properties2)
local tween22 = tweenService:Create(sail22, tweenInfoo1, Properties22)
local tween3 = tweenService:Create(sail3, tweenInfoo1, Properties3)
-----------------
local tweenOld1 = tweenService:Create(sail1, tweenInfoo1, PropertiesOld1)
local tweenOld11 = tweenService:Create(sail11, tweenInfoo1, PropertiesOld11)
local tweenOld2 = tweenService:Create(sail2, tweenInfoo1, PropertiesOld2)
local tweenOld22 = tweenService:Create(sail22, tweenInfoo1, PropertiesOld22)
local tweenOld3 = tweenService:Create(sail3, tweenInfoo1, PropertiesOld3)
local seat = script.Parent
script.Parent.MaxSpeed = script.Parent.Settings.MaxSpeed.Value
maxspeed = script.Parent.MaxSpeed
script.Parent.BodyPosition.Position = script.Parent.Position
script.Parent.BodyGyro.CFrame = script.Parent.CFrame
value1 = 0
while true do
wait()
if script.Parent.Throttle == 1 then
if value1 < maxspeed then value1 = value1 + script.Parent.Settings.Acceleration.Value end
tween1:Play()
tween11:Play()
tween2:Play()
tween22:Play()
tween3:Play()
script.Parent.Driving.Value = true
script.Parent.BodyVelocity.Velocity = script.Parent.CFrame.lookVector*value1
script.Parent.Left.Value = false
script.Parent.Right.Value = false
end
if script.Parent.Throttle == 0 then
tweenOld1:Play()
tweenOld11:Play()
tweenOld2:Play()
tweenOld22:Play()
tweenOld3:Play()
script.Parent.Driving.Value = false
script.Parent.BodyVelocity.Velocity = script.Parent.CFrame.lookVector*value1
script.Parent.Left.Value = false
script.Parent.Right.Value = false
end
if script.Parent.Throttle == -1 then
if value1 > - maxspeed then value1 = value1 -script.Parent.Settings.Acceleration.Value end
script.Parent.Driving.Value = true
script.Parent.BodyVelocity.Velocity = script.Parent.CFrame.lookVector*value1
script.Parent.Left.Value = false
script.Parent.Right.Value = false
end
if script.Parent.Steer == 1 then
script.Parent.BodyGyro.CFrame = script.Parent.BodyGyro.CFrame * CFrame.fromEulerAnglesXYZ(0,- script.Parent.Settings.TurnSpeed.Value,0)
tween1:Play()
tween11:Play()
tween2:Play()
tween22:Play()
tween3:Play()
script.Sound:Play()
script.Parent.Driving.Value = true
script.Parent.Right.Value = true
script.Parent.Left.Value = false
end
if script.Parent.Steer == -1 then
tween1:Play()
tween11:Play()
tween2:Play()
tween22:Play()
tween3:Play()
script.Sound:Play()
script.Parent.BodyGyro.CFrame = script.Parent.BodyGyro.CFrame * CFrame.fromEulerAnglesXYZ(0,script.Parent.Settings.TurnSpeed.Value,0)
script.Parent.Driving.Value = true
script.Parent.Left.Value = true
script.Parent.Right.Value = false
end
end
‘’’
I tried to change BodyVelocity.Velocity to 0
The boat doesnt works with Anchored parts.