Answered by
5 years ago Edited 5 years ago
So...
I was doing some experimentation with remote events and I realized that that was unnecessary because when a player sits in a driveseat that player becomes the network owner of the car and a localscript in the player's gui can modify the speed. (and anything else in the car) My carscript works by cloning a localscript into the player's gui with the code that makes the wheels turn left/right, so i added these lines of code to the script, as well as a bool value containing info whether shift was held in the player's pack, and a script that awarded a bool into the player's pack if they had the pass.
01 | local MPS = game:GetService( "MarketplaceService" ) |
02 | local turbokeyheld = player.Backpack.turbokeyheld |
03 | local hasPassBool = player.Backpack.HasSpeedPassBool |
04 | local staticspeed = stats.Speed.Value |
05 | turbokeyheld.Changed:connect( function () |
07 | if hasPassBool.Value = = true and turbokeyheld.Value = = true then |
09 | print ( "Car detected pass" ) |
13 | stats.Speed.Value = stats.Speed.Value + 35 |
15 | print (stats.Speed.Value) |
20 | elseif hasPassBool.Value = = true and turbokeyheld.Value = = false then |
22 | print ( "Car detected pass but key is not held" ) |
24 | if stats.Speed.Value < staticspeed then |
25 | stats.Speed.Value = stats.Speed.Value - 35 |
27 | stats.Speed.Value = staticspeed |
29 | print (stats.Speed.Value) |
34 | print ( "Car did not detect pass" ) |
35 | if stats.Speed.Value < staticspeed then |
36 | stats.Speed.Value = stats.Speed.Value - 35 |
38 | stats.Speed.Value = staticspeed |
40 | print (stats.Speed.Value) |