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:
plr = script.Parent.Parent mouse = plr:GetMouse() mouse.KeyDown:connect(function(key) if key == 13 then plr.Character.Humanoid.WalkSpeed = 30 end end) mouse.KeyUp:connect(function(keyy) if keyy == 13 then plr.Character.Humanoid.WalkSpeed = 16 end end)
THIS IS A NORMAL SCRIPT INSIDE STARTERPACK!
LOALSCRIPT
plr = game.Players.LocalPlayer m = plr:GetMouse() down = false m.KeyDown:connect(function(key) if key:lower() == "r" then down = true repeat print('keydown') wait() until down==false end end) m.KeyUp:connect(function(key) if key:lower() == "r" and down==true then down=false end end) --spyspace12
You should give this a shot...
plr = game.Players.LocalPlayer m = plr:GetMouse() hold = false function holdingkey() while hold == true do plr.Character.Humanoid.WalkSpeed = 30 end end m.KeyDown:connect(function(key) if key == 13 then hold = true holdingkey() end end m.KeyUp:connect(function(key) if key == 13 then hold = false end end
This worked for me. Hope it helps.
mouse.KeyDown:connect(function(key) if string.byte(key) == 13 then print("Enter") end end)