Hi everyone!
I was making code for whenever someone died, that a script would run that checks if the player was in the round already, and if they were, to teleport them back to map with a weapon. It wouldn't work so I put prints in the code to see where it had stopped:
(This is a regular script)
Main = require(game.Workspace.ModuleScripts.Main)
local playersinround = Main.CharacterList
local players = game:GetService("Players"):GetPlayers()
local SwordAccess = game:GetService("ReplicatedStorage").Swords
local sword = SwordAccess.BasicSword
game:GetService("Players").PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(charModel)
charModel:WaitForChild("Humanoid").Died:Connect(function()
playersinround = Main.CharacterList
print(plr)
plr.CharacterAdded:Wait(0.05)
for i = 1, #playersinround do
local player = playersinround[i]
print(player)
if player == plr then
print("1")
Main.ToBattleMap()
print("2")
local backpack = player:WaitForChild("Backpack")
if backpack then
local swordClone = sword:Clone()
swordClone.Parent = player
print("3")
end
end
end
end)
end)
end)
For some odd reason, all 4 prints print out in the output, but nothing happens in-game (No teleportation or weapon given). Can anyone tell me on how to fix this?
Any help on how to fix my code so it works is appreciated :)

1 comment
Try making the wait set to something like 3-5 seconds.