Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Problems with key equip tool?

--So currently I am trying to make the script below enable my tool "Transformation" to equip when I hit the key "b". Below is a local script inserted into the tool and there is a handle. I don't equip it the output states:" local tool = script.Parent tool.Equipped:connect(function(m:1: attempt to index global 'script' (a nil value) "

--I'm not sure why it doesn't work, mind helping?

local tool = script.Parent tool.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) if key == "b" then print( ("Equip Transformation.") ) end end) end)

--Thanks!

2 answers

My guess is that you need to have a keyboard listener outside of the Equip:connect event listener - otherwise you're listening to an event that can't be triggered by your keyboard, because the keyboard event isn't being initialized until that tool gets equipped - making it impossible for your desired results to happen.

This discussion is preserved as it was. New answers, comments, and votes are closed.