I made a table which includes weapons. When the parent of this script is clicked, I want to remove these tool(s) if they are present inside of the player in workspace. When I press the button, nothing happens. I'm new to tables so help would be appreciated.
local player = game.Players.LocalPlayer local character = player.Character function onClick() local weapons = { [character.M14] = "M14", [character.G36K] = "G36K", [character.Patriot] = "Patriot", } if character:FindFirstChild(weapons) then weapons:Destroy() end end script.Parent.MouseButton1Down:connect(onClick)
You are already calling the character from the table as well as outside of the table, which causes it to be very confusing.
Maybe try this.
local player = game.Players.LocalPlayer local character = player.Character function onClick() local weapons = { "M14", "G36K", "Patriot", } for i=1, #weapons do local item = character:FindFirstChild(weapons[i]) if item then item:Destroy() end end end script.Parent.MouseButton1Down:connect(onClick)