Ok so I have taken away the player's control of their character using the ControllerService, and now I want to make it so that when the player presses the space key, their character jumps. I have this in a LocalScript and it doesn't work. Can anyone figure out why? It works if I use a different key, but I want to use space.
game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(key) if key == Enum.KeyCode.Space then if plr.Character:FindFirstChild("on")then plr.Character.Humanoid.Jump = true print("jumped") end end end)
There is no such thing as Enum.KeyCode.Space. Instead use string.byte().
game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(key) if key:byte() == 32 then --The code for space is 32. if plr.Character:FindFirstChild("on") then plr.Character.Humanoid.Jump = true print("jumped") end end end)
How do I know that space is 32? Well just look on this chart, please note that some of the things on this chart do not work. BTW there are 4 different number columns, look under the one that says Dec on the top.
Hope this helps!