Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What's wrong with my script?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
Greetings fellow ROBLOXians
can i get some help on my script?
------------------------------------------------

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

mouse.KeyDown:connect(function(key)
if key == "2" then
player.Character.Humanoid.WalkSpeed = 50
mouse.KeyDown:connect(function(key)
if key == "2" and player.Character.Humanoid.WalkSpeed == 50 then
player.Character.Humanoid.WalkSpeed = 16
end
end)
end
end)
---------------------------------------------------------------------------------------------

 "2" = ctrl key when i press the ctrl key my walkspeed will be 50
however when i press the ctrl key again it says like this can i get some he

1 answer

Log in to vote
0
Answered by
yumtaste 476 Moderation Voter
9 years ago

When you put the key as "2," I think it's listening for the literal 2 number key. Try replacing line 9 on your posted script to if key:byte() == "2" then. That will make it listen for the key whose byte code is 2.

0
Same with the other line where you have an if statement. yumtaste 476 — 9y
0
that byte thing doesn't work MysticalGeek 0 — 9y
0
when i added :byte() to key the whole script won't work anymore MysticalGeek 0 — 9y
Ad

Answer this question