Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Xbox Gamepad Sprinting Help?

Asked by 6 years ago

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?

0
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. aoaoaoaoa00 4 — 6y

1 answer

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
6 years ago

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)
Ad

Answer this question