Anyone know how to make a ROBLOX character's walkspeed increase from 16 to about 25 when a button on an Xbox controller is pressed? The button I would like is L3 (or the left thumbstick pressed down) if it's possible? And when the player isn't pressing on it anymore how can I revert it back to walkspeed 16?
COMMUNITY QUESTION
Xbox Gamepad Sprinting Help?
1 answer
Read up on Gamepad Input on the roblox wiki http://wiki.roblox.com/index.php?title=Gamepad_Input
local uis = game:GetService('UserInputService')
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char.Humanoid
uis.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Gamepad1 then
if input.KeyCode == Enum.KeyCode.ButtonL3 then
hum.WalkSpeed = 25
end
end
end)
uis.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Gamepad1 then
if input.KeyCode == Enum.KeyCode.ButtonL3 then
hum.WalkSpeed = 16
end
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
I don't need code made for me, I need someone to explain to me how it'd work, and maybe leave the block of code so I can find out on my own time.