I'm working on a script, and I want it to target the equipped tool of the Player who touches a brick The only problem is that I have no idea how I could do this. It can't be a specific tool in the BackPack, because there can be many, but it has to be only the Equipped one. What kind of connection line could I use here?
You can create an event handler from anywhere, as far as I know. Since the LocalScript is a descendant of Player, we can loop through that player's backpack with a for loop and then create a handler for each tool in the backpack.
local plr = game.Players.LocalPlayer local backpack = plr:WaitForChild("Backpack") for i,v in pairs(backpack:GetChildren()) do if v.ClassName == "Tool" then v.Equipped:connect(function(mouse) --stuff end) end end
This is what you want, right?
Locked by BlueTaslem
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?