I'm trying to make a script that will increase a car's speed by 35 if the driver that is in it has a certain gamepass, and if a driver gets in that doesn't have the gamepass the car will run at the normal speed. Btw, the gamepass is a newer gamepass that only has a passid.
basically, i am trying to make a turbo function that only works if the driver has a certain gamepass and a certain key (shift) is held
there is a configurations folder in the car and a integer value named "Speed" in that folder that i am trying to change. in the player's backpack i also put an integer value, and my sprint script also changes that value if the player has the gamepass. But i can't get the value of the variable in the player's pack to sync with the value in the car's configuration folder. the car can detect the name of the player that is sitting in it. where do i put a script that detects the change in the player's speed variable (in the pack) and changes the car's speed variable to match, but only when the player is in the car?
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.
local MPS = game:GetService("MarketplaceService") local turbokeyheld = player.Backpack.turbokeyheld local hasPassBool = player.Backpack.HasSpeedPassBool local staticspeed = stats.Speed.Value turbokeyheld.Changed:connect(function() if hasPassBool.Value == true and turbokeyheld.Value == true then --if using with pass, take out the passbool stuff if you don't need a pass --print(player .. " owns the game pass with ID " .. 6331302) print("Car detected pass") --repeat --wait(0.1) stats.Speed.Value = stats.Speed.Value + 35 print(stats.Speed.Value) elseif hasPassBool.Value == true and turbokeyheld.Value == false then --print(player .. " owns the game pass with ID " .. 6331302 .. " aka the Turbo Pass") print("Car detected pass but key is not held") --stats.Speed.Value = 80 if stats.Speed.Value < staticspeed then --fallback if the speed keeps subtracting stats.Speed.Value = stats.Speed.Value - 35 else stats.Speed.Value = staticspeed end print(stats.Speed.Value) -- end else print("Car did not detect pass") if stats.Speed.Value < staticspeed then stats.Speed.Value = stats.Speed.Value - 35 else stats.Speed.Value = staticspeed end print(stats.Speed.Value) end --speed() end)