Scripting Issue

I’m having a problem with this script, basically when a player clicks a button it teleports them into a map. Whenever they die they will spawn back into the map but not with Spawn Locations but with specific coordinates. But the problem is that when the Player dies it doesn’t send the Player back to the Map.

You can check the script right below here.

  player.Character:WaitForChild(“Humanoid”).Died:Connect(function()
        wait(5)
         print(“Player has died”)
         player.CharacterAdded:Wait()
     if random == 1 then
      print(“Default 1”)
      player.Character.HumanoidRootPart.CFrame = CFrame.new(36.482, 
      74.652, 165.87)
    elseif random == 2 then
      print(“Default 2”)
       player.Character.HumanoidRootPart.CFrame = CFrame.new(-214.008, 
      73.652, 19.058)
  elseif random == 3 then
     print(“Default 3”)
     player.Character.HumanoidRootPart.CFrame = CFrame.new(-77.9, 73.652, -187.531)
 elseif random == 4 then
        print(“Default 4”)
        player.Character.HumanoidRootPart.CFrame = CFrame.new(209.438, 
   73.652, -47.832)
   elseif random == 5 then
            print(“Default 5”)
            player.Character.HumanoidRootPart.CFrame = 
            CFrame.new(19.52373.652,-61.998)
      end
end)

This is in a Local Script.

1 Like

It’s most likely due to the fact that when the Player dies, their PlayerGui is reset – therefore killing the script and it never fires. You can very well convert this script into a Server script for the same effect and it should fire.

Just wrap the code inside of a:

game.Players.PlayerAdded:Connect(function(player)
-- your code here
end)