There’s linear velocity and angular velocity being used. Below is the code:
local seat = script.Parent.VehicleSeat
local occupied = false
local force1 = script.Parent.base.LinearVelocity
local turn = script.Parent.base.AngularVelocity
--[[seat.Occupant.Changed:Connect(function()
print("reached")
if(occupied == false) then
occupied = true
else
occupied = false
force1.Enabled=false
end
end)]]
local currkey = nil
seat:GetPropertyChangedSignal("Throttle"):Connect(function()
print("reached")
if seat.Throttle==1 then
force1.LineVelocity=4000
force1.Enabled=true
elseif seat.Throttle==-1 then
force1.LineVelocity=-4000
force1.Enabled=true
force1.Enabled=false
end
end)
seat:GetPropertyChangedSignal("Steer"):Connect(function()
if seat.Steer==1 then
turn.AngularVelocity=Vector3.new(3, 0, 0)
turn.Enabled=true
elseif seat.Steer==-1 then
turn.AngularVelocity=Vector3.new(-3, 0, 0)
turn.Enabled=true
else
turn.Enabled=false
end
end)
Can someone help me? I don’t want it to slide when it moves. It turns in the right direction but keeps sliding.
Perhaps it’s something to do with my turning? I’m not sure…
Problem:
It seems like you are using LinearVelocity with VelocityConstraintMode property set to Line
The line mode will only apply force in the direction of the line, and will not apply any force that’s not in the direction of the line
For example, if the line is facing forward then it won’t apply any force to prevent sliding right and left and it will also not apply any force to stop it from going up and down Solution:
To prevent the car from sliding right and left you can add another Attachment and LinearVelocity with VelocityConstraintMode property set to Line, RelativeTo property set to Attachment0 and with the line facing right, also set the Attachment0 to the attachment you just created, not the one you used for forward and backward force
To make the LinearVelocity face right just rotate the attachment