I wanna know if this is the ‘cleanest’ way to go abouts this
local Sprinting = false
local function sprintFunction(actionName, inputState, inputObject)
if inputState == Enum.UserInputState.Begin then
if Sprinting then
if not GamepassCheck(Player, 'Running Shoes') then return end
if Humanoid.WalkSpeed == 0 then return end
Humanoid.WalkSpeed = 16
Sprinting = false
else
if not GamepassCheck(Player, 'Running Shoes') then return end
if Humanoid.WalkSpeed == 0 then return end
Humanoid.WalkSpeed = 24
Sprinting = true
end
end
end
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode ~= Enum.KeyCode.LeftShift or input.KeyCode == Enum.KeyCode.ButtonR2 then return end
if not GamepassCheck(Player, 'Running Shoes') then return end
if Humanoid.WalkSpeed == 0 then return end
Humanoid.WalkSpeed = 24
end)
UserInputService.InputEnded:Connect(function(input)
if input.KeyCode ~= Enum.KeyCode.LeftShift or input.KeyCode == Enum.KeyCode.ButtonR2 then return end
if not GamepassCheck(Player, 'Running Shoes') then return end
if Humanoid.WalkSpeed == 0 then return end
Humanoid.WalkSpeed = 16
end)
ContextActionService:BindAction("Sprint", sprintFunction, true, Enum.KeyCode.LeftShift, Enum.KeyCode.ButtonR2)
Basically, on pc and console, you hold down a key to sprint. Touch devices it’s you tap, sprinting is turned on, you tap again, it’s turned off (so they dont need to a hold a button down)
Also, is there a clean way to only create the touch button if they own the gamepass?