i need a script so that if a a object with a class name of "tool" is inside a player character it deletes it
i have this script but it does't do anything
local player = game.Players.LocalPlayer local character = player.Character local child = character:GetChildren() if child.ClassName == "Tool" then child:delete() end
no errors in the output, this is a part of a local script inside the text button
ServerScript (Script):
game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) for i,v in pairs(character:GetChildren()) do if v:IsA("Tool") then v:Destroy() end end end) end) --[[ what this does is when a player joins the game and gets it's character it checks if it has a tool equipped.if it has a tool equipped it deletes it, to make it check for tools only a certain time you can just add something that uses this script]]
LocalScript:
player = game.Players.LocalPlayer character = player.Character for i,v in pairs(character:GetChildren()) do if v:IsA("Tool") then v:Destroy() end end -- this script does the same thing as above. only checks the first time the player joins.