Game doesn't give reward / teleport players back to lobby

So, in my previous question, the game doesn’t teleport players into the arena. I have resolved this, but this introduces two more issues:

  1. Once a player wins the game, it doesn’t teleport them back to the lobby.

  2. The player is supposed to get a reward, but they don’t get it.

In this video, this shows the issues.

CODE: Code - Pastebin.com

Which part of the code has the issue? What have you tried so far to fix the issue?

Reward issue:

       if #plrs == 1 then
            -- Last person standing
            Status.Value = "The winner is "..plrs[1].Name
            plrs[1].leaderstat.Bits.Value = plrs[1].leaderstats.Bits.Value + 25
            break

I’m not sure which part of the code doesn’t teleport the player that won back to the lobby…

plrs[1].leaderstat.Bits.Value
leaderstat should be leaderstats.

1 Like

It works! Thank you for the fix!
And now, the player that won the game can teleport back to the lobby!

Oh - cool! Would you mind pointing out where it teleports back to the lobby? (idk why I couldn’t figure out where it was :smile:)

1 Like

The code or how it works?

Just where the code itself is in the pastebin - I must have missed it when I read over the pastebin.

   for i, player in pairs(game.Players:GetPlayers()) do
    character = player.Character
   
    if not character then
        -- Ignore them
    else
        if character:FindFirstChild("GameTag") then
            character.GameTag:Destroy()
        end
       
        if player.Backpack:FindFirstChild("Sword") then
            player.Backpack.Sword:Destroy()
        end
        if character:FindFirstChild("Sword") then
            character.Sword:Destroy()
        end
       
        player:LoadCharacter()
    end
end

ClonedMap:Destroy()

Status.Value = "Game over!"

wait(2)

end

This might be the code of how it teleports the players back to the lobby.

Does :LoadCharacter move them to a lobby in the spawn?

I think so.

Have you tried to assign those players to a team and assign the spawns to a team too?

No, I haven’t tried that.

Try that

I’m following a tutorial series.
I could do that later…

            if character:FindFirstChild("GameTag") then
                character.GameTag:Destroy()
            end
           
            if player.Backpack:FindFirstChild("Sword") then
                player.Backpack.Sword:Destroy()
            end
            if character:FindFirstChild("Sword") then
                character.Sword:Destroy()
            end

my suspicions is that you have two tools which I think may be called “Sword” which may be the case why the tools didn’t delete in the first place and throw an error.

I noticed that too.
I later found out I was being dumb and putted a sword into StarterPack, and I deleted the sword in StarterPack, and it’s fixed.

Issue with :LoadCharacter?

Nah.

What is the output? IF none try adding prints around your code to detect where the bug is at.

1 Like