Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make the player run faster after pressing a button?

How would I make the player run fast/start sprinting when they hold down the shift key?

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

1 comment

0

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

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.