I have this script for custom spawners. When a player joins they are assigned a spawner. When they leave it is removed. I want to make it so that when they reset they go back to their assigned spawner. How can I do this? I found a spawn function on the wiki, but it looked like it was for something else.
-How to I make it so that when they reset they go to their assigned spawner?
local AvailableSpawners = {game(dot)Workspace(dot)Spawner1-6[Roblox Filters my code out here]}
local TakenSpawners = {}
game.Players.PlayerAdded:Connect(function(plr)
local random = math.random(1 , #AvailableSpawners)
local spawner = AvailableSpawners[random]
table.remove(AvailableSpawners , random)
table.insert(TakenSpawners , spawner)
spawner.Owner.Value = plr.Name
plr.CharacterAdded:Connect(function(char)
char:MoveTo(spawner.Position)
end)
end)
-------------------------------------------
game.Players.PlayerRemoving:Connect(function(plr)
for i , v in TakenSpawners do
if v.Owner.Value == plr.Name then
v.Owner.Value = "NoOwner"
table.remove(TakenSpawners , i)
table.insert(AvailableSpawners , v)
end
end
end)
|