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.
01 | player = game.Players.LocalPlayer |
02 | tool = script.Parent |
03 | handle = tool.Handle |
04 | tool.Equipped:Connect( function (mouse) |
05 | mouse.KeyDown:connect( function (key) |
06 | if key = = "f" then |
07 | player.Character.Humanoid.Jump = true |
08 | end |
09 | end ) |
10 | 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