Anyone know how this could be done?
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.
1 | local player = nil |
2 | YOURPART.ChildAdded:connect( function (child) |
3 | if child.Name = = "SeatWeld" then |
4 | player = game.Players:GetPlayerFromCharacter(YOURPART.Occupant.Parent) |
5 | end |
6 | 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.
1 | for i,v in pairs (THING:GetChildren()) do |
2 |
3 | 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