local UserInpServ = game:GetService('UserInputService')
local ReplicatedStorage = game:GetService('ReplicatedStorage')
UserInpServ.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.E then
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 72
else
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 25
end
end)
-- help
COMMUNITY QUESTION
i wanna make it so when i'm not holding it stops but it still running fast - ?
1 answer
Formatting your code
Firstly, I formatted your code in a code block for you.
local UserInpServ = game:GetService('UserInputService')
local ReplicatedStorage = game:GetService('ReplicatedStorage')
UserInpServ.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.E then
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 72
else
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 25
end
end)
The issue
Basically, you need to check if the keycode was E when the input ends, which will detect that it was held and you can set the walkspeed back.
Here is a fixed script
local UserInpServ = game:GetService('UserInputService')
local ReplicatedStorage = game:GetService('ReplicatedStorage')
UserInpServ.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.E then
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 72
end
end)
UserInpServ.InputEnded:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.E then
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 25
end
end)
Thanks
Thanks for reading, hope I helped.
:-)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Please format with a code block.
done i need to go right now sorry, byee