I'm trying to make the player's walkspeed change to 30 while the enter key is being held down. And when it gets released, it changed back to 16.
But its not working
Script:
01 | plr = script.Parent.Parent |
02 | mouse = plr:GetMouse() |
03 |
04 | mouse.KeyDown:connect( function (key) |
05 | if key = = 13 then |
06 | plr.Character.Humanoid.WalkSpeed = 30 |
07 | end |
08 | end ) |
09 |
10 | mouse.KeyUp:connect( function (keyy) |
11 | if keyy = = 13 then |
12 | plr.Character.Humanoid.WalkSpeed = 16 |
13 | end |
14 | end ) |
THIS IS A NORMAL SCRIPT INSIDE STARTERPACK!
LOALSCRIPT
01 | plr = game.Players.LocalPlayer |
02 | m = plr:GetMouse() |
03 | down = false |
04 |
05 |
06 | m.KeyDown:connect( function (key) |
07 | if key:lower() = = "r" then |
08 | down = true |
09 | repeat |
10 | print ( 'keydown' ) |
11 | wait() |
12 | until |
13 | down = = false |
14 | end |
15 | end ) |
You should give this a shot...
01 | plr = game.Players.LocalPlayer |
02 | m = plr:GetMouse() |
03 | hold = false |
04 |
05 | function holdingkey() |
06 | while hold = = true do |
07 | plr.Character.Humanoid.WalkSpeed = 30 |
08 | end |
09 | end |
10 |
11 | m.KeyDown:connect( function (key) |
12 | if key = = 13 then |
13 | hold = true |
14 | holdingkey() |
15 | end |
This worked for me. Hope it helps.
1 | mouse.KeyDown:connect( function (key) |
2 | if string.byte(key) = = 13 then |
3 | print ( "Enter" ) |
4 | end |
5 | end ) |