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

Why is my shift to sprint script not making my character run?

I tried all i could to find n error, but i couldn't. Even the output said nothing.

-- Made by wookey12 :)
wait(1)
local player = game.Players.LocalPlayer
local mouse = game.Players.LocalPlayer:GetMouse()

mouse.KeyDown:Connect(function(KeyDown)
	if KeyDown == 48 then
		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 30
	end
end)

mouse.KeyUp:Connect(function(KeyUp)
	if KeyUp == 48 then
		player.Character.Humanoid.WalkSpeed = 16
	end
end)

1 comment

0

KeyDown is deprecated.

1 answer

✓ Accepted answer

First of all, try to make ":Connect" into ":connect", and maybe that will help.

Second of all, use

if KeyDown:byte() == 19 then

on those things instead of

if KeyDown == 19 then

It seems to work for me, I used a script in a game I'm making with that sort of idea:

local mouse = game.Players.LocalPlayer:GetMouse()

function onkeyDown(key)
	if key:byte() == 19 then
		if script.Parent.CurrentOption.Value == "Fight" then
			script.Parent.CurrentOption.Value = "Act"
			script.Parent.Fight.Image = "rbxgameasset://Images/spr_fightbt_center_0"
			script.Parent.Act.Image = "rbxgameasset://Images/spr_actbt_center_1"
			script.Parent.Act.Heart.Visible = true
			script.Parent.Fight.Heart.Visible = false
		elseif script.Parent.CurrentOption.Value == "Act" then
			script.Parent.CurrentOption.Value = "Item"
			script.Parent.Act.Image = "rbxgameasset://Images/spr_actbt_center_0"
			script.Parent.Item.Image = "rbxgameasset://Images/spr_itembt_1"
			script.Parent.Item.Heart.Visible = true
			script.Parent.Act.Heart.Visible = false
		elseif script.Parent.CurrentOption.Value == "Item" then
			script.Parent.CurrentOption.Value = "Mercy"
			script.Parent.Item.Image = "rbxgameasset://Images/spr_itembt_0"
			script.Parent.Mercy.Image = "rbxgameasset://Images/spr_sparebt_1"
			script.Parent.Mercy.Heart.Visible = true
			script.Parent.Item.Heart.Visible = false
		elseif script.Parent.CurrentOption.Value == "Mercy" then
			script.Parent.CurrentOption.Value = "Fight"
			script.Parent.Mercy.Image = "rbxgameasset://Images/spr_sparebt_0"
			script.Parent.Fight.Image = "rbxgameasset://Images/spr_fightbt_center_1"
			script.Parent.Fight.Heart.Visible = true
			script.Parent.Mercy.Heart.Visible = false
		end
	end 
end

mouse.KeyDown:connect(onkeyDown)

5 comments

0

Please gimme some points c;

0

I refuse to give you points since you didn't exactly point him in the proper direction. KeyDown is deprecated.

0

Thanks! Worked like a charm!

0

Well I still used it anyways... I don't know how to use the other way that well xD

0

You can use :connect, but it's deprecated. Use :Connect

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