Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Applying maximum speed doesn't work?

Asked by 6 years ago

So I'm making a Model that is hovering on the ground (thanks to a BodyPosition that's Position is set a little above the ground and it's MaxForce is set to 0, 40000, 0) and can be steered. The model consists of a Part (in which is a Script, a BodyGyro, BodyPosition and a BodyVelocity) and a VehicleSeat that is welded to the Part. The Script makes it so the signals sent by the player to VehicleSeat are changing the properties of BodyGyro and BodyVelocity. This is how it looks:

01local RunService = game:GetService("RunService")
02local part = script.Parent
03local bodyGyro = part.BodyGyro
04local bodyVel = part.BodyVelocity
05local seat = script.Parent.Parent.VehicleSeat
06local goBack, goForward = false, false
07local turnLeft, turnRight = false, false
08 
09local maxForward = 20
10local maxBack = -10
11 
12seat:GetPropertyChangedSignal("Occupant"):Connect(function(char)
13    local currentSpeed = 0
14    local currentAngle = 0
15    RunService.Heartbeat:Connect(function(step)
View all 49 lines...

The Model speeds up fine and rotates fine too, but the maximum speed I applied to it doesn't do anything. The speed easily goes above 20. I tried doing other things to fix it but nothing worked. Thanks for reading.

0
I'm not too familiar with using forces, but have you tried setting max speed to much lower values? Other then that I could see using heartbeat causing a railgun effect since it's run so often, try putting a /60 after currentSpeed on line 16 maybe clc02 553 — 6y
0
It just makes the Model speed up slower Tymberlejk 143 — 6y

1 answer

Log in to vote
2
Answered by 6 years ago
01local RunService = game:GetService("RunService")
02local part = script.Parent
03local bodyGyro = part.BodyGyro
04local bodyVel = part.BodyVelocity
05local seat = script.Parent.Parent.VehicleSeat
06local goBack, goForward = false, false
07local turnLeft, turnRight = false, false
08 
09local maxForward = 20
10local maxBack = -10
11 
12 
13local waitTime = 0.1--bigger it gets, slower boat will be
14seat:GetPropertyChangedSignal("Occupant"):Connect(function(char)
15    local currentSpeed = 0
View all 60 lines...

I believe this should work, but I'm not sure why you need those booleans and checking them for nothing at 1, 2, 3 and 4 and then reassigning them you aren't using them, so to keep Code clean I recommend you to put them out

Ad

Answer this question