Anyone know how this could be done?
how to make a script where when a player sits all their tools from backpack gets destoryed?
1 answer
Seats (and all Instances for that matter) have an event by the name of ChildAdded. It's accessed by a line such as YOURPART.ChildAdded:connect(function(child).
The variable 'child' will give you the child added. You can use an if statement to check the name of the child, which will allow you to find the player.
local player = nil
YOURPART.ChildAdded:connect(function(child)
if child.Name == "SeatWeld" then
player = game.Players:GetPlayerFromCharacter(YOURPART.Occupant.Parent)
end
end)
As for the backpack, this is accessed within each player by using PLAYER.Backpack.
There is a function called :GetChildren(), which will allow you to do what you require.
For loops reiterate over each value in an array.
for i,v in pairs(THING:GetChildren()) do
end
This is a for loop. The variable 'v' signifies an object, which could then be destroyed with v:Destroy().
Hope this helped.
Thanks,
Explosion
2 comments
What does YOURPART & THING repersent? is it the player
In your case, YOURPART would be the seat, whilst THING would be player.Backpack.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Sorry for the typo