Hello, so, I was looking for some videos on how to Script a Console Sprint Button but there were non so I might ask here.
4 Likes
Are you able to provide some more information as the information given is fairly limited. Do you need help making a button that you click to sprint? A sprint command? What do you mean by a console script button?
Oh, my apologies, I want to script a Console Sprint Button, for example, if I press, Left trigger, the Character would sprint, if I let go, the Character would stop sprinting
Do you mean a button that works on console?
1 Like
All you have to do is use UserInputService
and make the character sprint when the correct keycode is pressed, and stop sprinting when it’s not.
local plr = game.Players.LocalPlayer --Player
local sprintSpeed = 30 --Configuration
local normalSpeed =16
local function sprintCharacter(on) --Function makes it easier to control with just a boolean
if plr.Character then
if on then --If it's on, set the walkspeed to sprinting
plr.Character.Humanoid.WalkSpeed = sprintSpeed
else --If it's not, set the walkspeed to normal
plr.Character.Humanoid.WalkSpeed = normalSpeed
end
end
end
game:GetService("UserInputService").InputBegan:connect(function(input, processed)
if input.UserInputType == Enum.UserInputType.Gamepad1 then
if input.KeyCode == Enum.KeyCode.ButtonL2 then --When the gamepad left trigger is pressed
sprintCharacter(true) --Sprint
end
end
end)
game:GetService("UserInputService").InputEnded:connect(function(input, processed)
if input.UserInputType == Enum.UserInputType.Gamepad1 then
if input.KeyCode == Enum.KeyCode.ButtonL2 then --When the gamepad's left trigger is released
sprintCharacter(false) --Stop sprinting
end
end
end)
Note, change the keycode to a different button if you want.
Image from wiki:
8 Likes
Ahh thank you, it worked, it means alot for me
1 Like