I'm trying to make a script that does the following things -add 4 gears to a car -gear 4 only works if you have a gamepass - all shifted with z/x or L1/R1
the script is part of my localcarscript that gets copied into the player's playergui folder when it is driven.
here is my code so far
local player = game.Players.LocalPlayer
local stats = car:WaitForChild("Configurations")
local CAS = game:GetService("ContextActionService")
local staticspeed = stats.Speed.Value
local MPS = game:GetService("MarketplaceService")
local cargear = script.Gear.Value
function geardown(name,state,action)
if state == Enum.UserInputState.Begin then
elseif state == Enum.UserInputState.End then
cargear = cargear - 1
if cargear < 1 then
cargear = 1
end
end
end
function gearup(name,state,action)
if state == Enum.UserInputState.Begin then
elseif state == Enum.UserInputState.End then
cargear = cargear + 1
if cargear > 4 then
cargear = 4
end
end
end
script.Gear.Changed:connect(function()
if cargear == 1 then
stats.Speed.Value = 20
elseif cargear == 2 then
if 55 > staticspeed then
cargear = 3
else
stats.Speed.Value = 55
end
elseif cargear == 3 then
stats.Speed.Value = staticspeed
elseif cargear == 4 and MPS:UserOwnsGamePassAsync(player.UserId,6331302) then
stats.Speed.Value = stats.Speed.Value + 35
elseif cargear == 4 and not MPS:UserOwnsGamePassAsync(player.UserId,6331302) then
cargear = 3
end
end)
CAS:BindActionToInputTypes("GearDown", geardown, true, Enum.KeyCode.Z, Enum.KeyCode.ButtonL1)
CAS:SetPosition("GearDown", UDim2.new(.25,0,.25,0))
CAS:SetTitle("GearDown", "Down")
CAS:BindActionToInputTypes("GearUp", gearup, true, Enum.KeyCode.X, Enum.KeyCode.ButtonR1)
CAS:SetPosition("GearUp", UDim2.new(.10,0,.25,0))
CAS:SetTitle("GearUp", "Up")
when i run it in studio there is no output, and the car stays in gear 3 (which is the default value of the gear integer)
