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

how do I make left control to toggle sprint?

local plr = game.Players.LocalPlayer
local char = plr.Character
local humanoid = char.Humanoid
local mouse = plr:GetMouse()
local r = 1

mouse.KeyDown:connect(function(key)
	if key == "LCtrl" and r == 1 then
		r = 2
		humanoid.WalkSpeed = 40
	elseif key == "LCtrl" and r == 2 then
		r = 1
		humanoid.WalkSpeed = 16
	end
end)

this is my script but I don't know what the script recognizes as the left control key

1 answer

✓ Accepted answer

If the key is LeftControl then it logs your speed and changes it to 100. When you let go of it, it reverts back to your old speed. :D

local UserInputService = game:GetService("UserInputService");

local currWalkSpeed;

UserInputService.InputBegan:connect(function(input) -- press
	if input.KeyCode == Enum.KeyCode.LeftControl then
		currWalkSpeed = game.Players.LocalPlayer.Character.Humanoid.WalkSpeed;
		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 100;
	end
end);

UserInputService.InputEnded:connect(function(input) -- release
	if input.KeyCode == Enum.KeyCode.LeftControl then
		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = currWalkSpeed;
	end
end);

3 comments

0

stop spoonfeeding idot take my downvote

0

Is call helping.

0

someones triggered and thanks

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