Hey, i was following a video tutorial from peas factory about key pressed event. I followed everything he did in that video and i wanted to test myself by trying something new. I wanted my character to jump when a key was pressed but i don't really know how to do it. I also looked up the roblox wiki page and i found out that Humanoid.Jump is a bool value, so if i want my character to jump i must set it to true. I was wondering if someone could help me with my script.
player = game.Players.LocalPlayer tool = script.Parent handle = tool.Handle tool.Equipped:Connect(function(mouse) mouse.KeyDown:connect(function(key) if key == "f" then player.Character.Humanoid.Jump = true end end) end)
Also i inserted a tool in the starter pack,a part called "Handle" in the tool and the script i used was a local script so there are no tehnical issues to call them this way.
Thanks in advance for helping me!
Are you sure that tool.Equipped:Connect(function(mouse) the tool.Equipped event will return your player’s mouse?
here’s a solution remove the mouse, then add a new variable named
local mouse = player:GetMouse()
under the player variable, also using global variables are generally bad habits in Lua, you want to local every variable, for speed and performance bonuses