Hello fellow users, I have a game which the tools are instead parts welded to player hands because I do only one time per time (just like Piggy or Teddy) and when the round ends the person still have the item if they survived.
Heres the code I tried:
1 | function deletePlayersItens() |
2 | for i,v in pairs (game.Players:GetChildren()) do |
3 | if v.Name = = "Key" then |
4 | print ( "KABOOOM" ) |
5 | v:Destroy() |
6 | end |
7 | end |
8 | end |
No errors in output, simply nothing. Please help, LyricalFrog3.
You're listing through PLAYER List, not their backpacks. You simply just need to loop through players and after it their backpacks With something like this:
01 | function deletePlayersItens() |
02 | for _,v in pairs (game.Players:GetChildren()) do |
03 | for _, Tool in pairs (v.Backpack:GetChildren()) do |
04 | if v.Name = = "Key" then |
05 | print ( "KABOOOM" ) |
06 | v:Destroy() |
07 | end |
08 | end |
09 | end |
10 | end |
not a advanced scripter im really bad at scripting but I maybe saw a typo. Didn't test but might work.
01 | function deletePlayersItems() --- you wrote itens instead of items |
02 | for _,v in pairs (game.Players:GetChildren()) do |
03 | for _, Tool in pairs (v.Backpack:GetChildren()) do |
04 | if v.Name = = "Key" then |
05 | print ( "KABOOOM" ) |
06 | v:Destroy() |
07 | end |
08 | end |
09 | end |
10 | end |