Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Problems with key equip tool?

Asked by 9 years ago

--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

Log in to vote
0
Answered by 9 years ago

Is it in a local script and are you using a Handle?

0
yes Cuteandwild 0 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

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.

Answer this question