so I am making a game loop and in this game loop, it enables a separate script to teleport any players that died to a random spawn however it will only load the character and nothing else, not even an error. So then I added prints to the script it seems like all the prints trigger but it still won't teleport the player. (Note: I am using an object value to tell the script what the map object is.)
ReplicatedStorage = game:GetService("ReplicatedStorage")
GameOn = ReplicatedStorage.Game
Maps = ReplicatedStorage:WaitForChild("Map")
game.Players.PlayerAdded:Connect(function(plr)
local chr = plr.Character or plr.CharacterAdded:wait()
local hum = chr.Humanoid
hum.Died:Connect(function()
print("Player has died")
if GameOn.Value == false then
plr:LoadCharacter() -- Loading the character
print("LoadCharacter")
else
print("Respawn")
wait(3)
plr:LoadCharacter() -- Loading the character
end
local Spawns = Maps.Value:FindFirstChild("Spawns"):GetChildren() -- Get spawns
local RandomSpawn = Spawns[math.random(1, #Spawns)] -- Pick a Random Spawn
print("Chosing spawn")
if chr and hum and chr:FindFirstChild("HumanoidRootPart") then
print("Chosing")
chr.HumanoidRootPart.CFrame = RandomSpawn.CFrame -- Put player on picked spawn
print("Spawn Chosen and teleporting")
end
print("Teleported")
end)
end)
