How would I make the player run fast/start sprinting when they hold down the shift key?
COMMUNITY QUESTION
How do I make the player run faster after pressing a button?
2 answers
Insert a RemoveEvent in the workspace and name it ServerChange. Place a script inside and type these lines:
script.Parent.OnServerEvent:Connect(function(Nothing, Item, Property, Val)
Item[Property] = Val
end)
Insert another LocalScript into StarterGui and type these lines:
game:GetService("UserInputService").InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
workspace.ServerChange:FireServer(game.Players.LocalPlayer.Character.Humanoid, "WalkSpeed", 20)
end
end)
Hope this helped send a comment if it didn't
Or Just make an easier script like this:
local uis = game:GetService("UserInputService") --Search for UserInput Service
uis.InputBegan:Connect(key)
if key.KeyCode == Enum.KeyCode.LeftShift then --If LeftShift Pressed, then Player speed = 25
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 25
end
end)
uis.InputEnded:Connect(function(key)
if key.KeyCode == Enum.KeyCode.LeftShift then --If LeftShift Press Ended, then Player speed = 16
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Do not use RemoteEvents like that because exploiters can exploit the game with that. You can also just set the WalkSpeed on the client.