I’m having problems with spawning players. I have a custom system setup to spawn players only at specific times.
Code: messy code lmao - Pastebin.com
(Only line 119 and on is relevant)
For some reason, it says there are two players alive, though when I run a dev command to teleport to the other player, nothing happens, because the player’s character does not exist.
Code for spawning/despawning players:
game.ReplicatedStorage.OtherEvents.SpawnPlayers.Event:Connect(function()
for i, v in pairs(game.Players:GetPlayers()) do
local char = v.Character
if char==nil then v:LoadCharacter() return end
if char.Humanoid.Health<=0 then v:LoadCharacter() return end
end
end)
game.ReplicatedStorage.OtherEvents.DespawnPlayers.Event:Connect(function()
for i, v in pairs(game.Players:GetPlayers()) do
local char = v.Character
if char~=nil then v.Character=nil return end
end
end)
Both scripts are in ServerScriptService.
In Deathmatch, which is where the problem takes place (Artillery and Capture are unimplemented, ignore them) all players are spawned in with respawning disabled, and the last man standing wins.
I’ve tried adding more points in the code to spawn players, but it doesn’t seem to work.