Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is the player still on the map when eliminated?

Asked by 9 years ago

Hey guys,

I'm making a round-based game that has "Elimination" in it. If you die, you shouldn't be on the map. Apparently, I tested the codes below but it didnt work...

ELIMINATION ROUND CODE

function Elimination()
    workspace.Ingame.Value = true
    workspace.Elimination.Value = true
    Text = "Round Chosen: Elimination"
    for i=1,#Text do
        game.Workspace.Lobby.Noti.SurfaceGui.TextLabel.Round.Text = Text:sub(1,i)
        wait(0.1)
    end
    ChooseMap()
    Map = "Map Chosen: "..chosen.Name
    for i=1,#Map do
        game.Workspace.Lobby.Noti.SurfaceGui.TextLabel.Map.Text = Map:sub(1,i)
        wait(0.1)
    end
    game.Workspace:WaitForChild(chosen.Name).Name = "Map"
    ChooseTeam()
    players = game.Players:GetPlayers()
    for i=1,#players do
        players[i]:LoadCharacter()
    end
    game.Workspace.Time.Value = 5*60
    game.Teams.Playing.ChildRemoved:connect(function(player)
        teamplayers = game.Teams.Playing:GetChildren()
        if #teamplayers == 1 then
            workspace.Ingame.Value = false
            teamplayers[1].leaderstats.Cash.Value = teamplayers[1].leaderstats.Cash.Value + 20
            workspace.Time.Value = 0
            workspace.Lobby.Noti.SurfaceGui.TextLabel.Text = teamplayers[1].Name.." Has won the round"
            wait(5)
        end
    end)
    while wait() do
        if game.Workspace.Time.Value == 0 then
            workspace.Ingame.Value = false
            for i=1,#players do
                if game.Players:FindFirstChild(players[i]) then
                items = players[i].Backpack:GetChildren()
                for b = 1,#items do
                    if items[b]:IsA("Tool") then
                        items[b]:Destroy()
                    end
                end
                players[i].TeamColor = game.Teams["Not Playing"].TeamColor
                wait()
                players[i]:LoadCharacter() end
            end
            game.Workspace:FindFirstChild("Map"):Destroy()
            break
        end
    end
    workspace.Elimination.Value = false
end

Humanoid.Died code * This is a LocalScript*

Humanoid.Died:connect(function()
    if workspace.Elimination.Value == true then
        game.Players.LocalPlayer.TeamColor = game.Teams["Not Playing"].TeamColor
        game.Players.LocalPlayer:LoadCharacter()
    end
end)

1 answer

Log in to vote
0
Answered by
iFlusters 355 Moderation Voter
9 years ago

Try doing this in a LocalScript and place it in their StarterPack/Gui:

wait(2)

player = script.Parent.Parent

while true do
wait()
if player.Character.Humanoid.Health == 0 then
player.TeamColor = game.Teams["Not Playing"].TeamColor
end
end
Ad

Answer this question