I am trying to make a minigame when one player has a tool and leads the other players with this tool. I made buttons that should close doors when the player with the tool clicks them, but I can't figure out how to check if a player has a certain tool.
Thanks!
secretassassin3, Use this for if the tool should be selected.
local button = script.Parent door1 = workspace.Doors.Door1 function onClicked(playerWhoClicked) local characterBits = playerWhoClicked.Character:GetChildren() -- The different parts of the character. for i, bit in pairs(characterBits) do if bit.ClassName == "Tool" then -- Or change ".ClassName == 'Tool'" to ".Name == 'the name of the tool here'" to make it so that only that tool closes the door. door1.Transparency = .2 door1.CanCollide = true end end end
Use this for if the tool should not be selected.
function onClicked(playerWhoClicked) local tools = playerWhoClicked.Backpack:GetChildren() -- The different parts of the character. for i, tool in pairs(tools) do if tool.ClassName == "Tool" then -- Or change ".ClassName == 'Tool'" to ".Name == 'the name of the tool here'" to make it so that only that tool closes the door. door1.Transparency = .2 door1.CanCollide = true end end end
Sincerely, crazycittykat