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
1 | local player = game.Players.LocalPlayer |
2 | local character = player.Character |
3 | local child = character:GetChildren() |
4 | if child.ClassName = = "Tool" then |
5 | child:delete() |
6 | end |
no errors in the output, this is a part of a local script inside the text button
ServerScript (Script):
01 | game.Players.PlayerAdded:Connect( function (player) |
02 | player.CharacterAdded:Connect( function (character) |
03 | for i,v in pairs (character:GetChildren()) do |
04 | if v:IsA( "Tool" ) then |
05 | v:Destroy() |
06 | end |
07 | end |
08 | end ) |
09 | end ) |
10 |
11 | --[[ 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:
1 | player = game.Players.LocalPlayer |
2 | character = player.Character |
3 | for i,v in pairs (character:GetChildren()) do |
4 | if v:IsA( "Tool" ) then |
5 | v:Destroy() |
6 | end |
7 | end |
8 |
9 | -- this script does the same thing as above. only checks the first time the player joins. |