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

How to add the shift command for sprint...?

1 answer

Sir, this is not requesting website. But i can teach you how to make it.

First: Found keycode.
You need to found what keys does the player input.
Then you can use this code.

function onKeyPress(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode."TheKeyCode" then
		--Make what you want.
	end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)

Remember to change "TheKeyCode" to LeftShift.
This code means when you pressed TheKeyCode, then Make what you want. will happen.

Second: Found player's moving speed.
It's time to speed up your character!
Then you need to found your character first.

local Player = game:GetService('Players').LocalPlayer --This means found "Player", but not Character yet!
local FakeCharacter = Player.Character or Player.CharacterAdded:Wait() --Means found "Character", still not real character...
local Character = FakeCharacter:WaitForChild('Humanoid') --This is real character, It's Humanoid.

We found all Character now! Now we need to found Player's speed.
The player has a lot of valid member, we only need his WalkSpeed.

Character.WalkSpeed = 16
--WalkSpeed is in the Humanoid, the original speed is 16(Means 16 studs every 1 seconds.)
--you can choose any speed you want.

third: Mix them.
Maybe you can do it by your self! Don't be a dumb. :)
Just put Second code in to the First code. Hope you enjoy learning Lua!
Reference Video:From Youtube

2 comments

0

Actually, the speed is 16 studs/s, not 16 studs/10s

0

i search that from wiki. xD Thank for correct!

This discussion is preserved as it was. New answers, comments, and votes are closed.