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.
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