I have a Pistol tool and a SMG tool and I trying to write code for both. I can't get anything to work
local player = game.Workspace.LocalPlayer local tool = player:FindFirstChildOfClass("Tool")
There's multiple ways you can do this.
Table:
local tools = { ["Pistol"] = player.Backpack:FindFirstChild("Pistol"), ["SMG"] = player.Backpack:FindFirstChild("SMG"), } print(tools.Pistol, tools.SMG)
Looping:
for i, v in pairs(player.Backpack:GetChildren()) do -- gets the backpack's children and checks if the child (v) is a tool if v:IsA("Tool") then local tool = v -- code end end