Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- seat = script.Parent
- power = seat.Parent.Parent.Control:GetChildren()
- eng = { }
- function GetEngines()
- for _, wheels in pairs(seat.Parent.Parent.Control:GetChildren()) do
- if (wheels.Name == "Engine") then
- local bv = script.BodyVelocity:Clone()
- bv.Parent = wheels
- eng[#eng + 1] = wheels
- end
- end
- end
- wait(3)
- GetEngines() -- This is the function that lagged the hell out of the game when it was after the next few lines
- while wait(0.1) do
- local maxspeed = seat.MaxSpeed
- for _, a in pairs(eng) do
- a.BodyVelocity.Velocity = (maxspeed * (seat.Current.Value / 100)) * a.CFrame.lookVector
- end
- if seat.Velocity.Magnitude < 0.5 and seat.Current.Value <= 0 then
- seat.Current.Value = 0
- for _, a in pairs(eng) do
- a.Anchored = true
- end
- else
- for _, a in pairs(eng) do
- a.Anchored = false
- end
- end
- if seat.Current.Value > 100 then
- seat.Current.Value = 100
- end
- if seat.Current.Value < -20 then
- seat.Current.Value = -20
- end
- if seat.Velocity.Magnitude > maxspeed and seat.Current.Value > 0 then
- for _, a in pairs(eng) do
- a.BodyVelocity.Velocity = Vector3.new(0,0,0)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement