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

Why doesn't my script affect all players where it should?

Asked by 8 years ago

The issue with the below script is that it teleports one players, and after the Blue player is affected, it teleports another player to the position and so on, how do I edit this script to teleport all players and then affect blue team and red team separately?

local blue = game.ServerStorage.Blue
local red = game.ServerStorage.Red


while true do wait(1)
    if blue.Value >= 100 then
        blue.Value = 0
        red.Value = 0
        game.Workspace:findFirstChild("Map"):Remove()
        mapstorage = game.ServerStorage.Maps:GetChildren()
        maps = mapstorage[math.random(1,#mapstorage)]
        local newmap = maps:Clone()
        newmap.Parent = game.Workspace
        newmap.Name = "Map"
        game.Workspace.Lobby.Music:Play()

        for _, player in pairs(game.Players:GetPlayers()) do -- ALL PLAYERS - Mainly this part.
            player.Character:MoveTo(game.Workspace.Resp.Position)
            player.PlayerGui.BlueWin.Frame.Visible = true
            player.PlayerGui.Int.Frame.Visible = true

            if player.TeamColor == BrickColor.new("Bright blue") then -- BLUE TEAM ONLY
                local spawnb = game.Workspace.Map.Spawns.Blue
                player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 500
                wait(20)
                player.PlayerGui.Int.Frame.Visible = false
                player.Character:MoveTo(spawnb.Position)

            elseif player.TeamColor == BrickColor.new("Bright red") then -- RED TEAM ONLY
                local spawnr = game.Workspace.Map.Spawns.Red
                player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 100
                wait(20)
                player.PlayerGui.Int.Frame.Visible = false
                player.Character:MoveTo(spawnr.Position)
            end
        end
    end
end
0
Nevermind this question, it was a problem with placing my ends incorrectly. excellentAnarchy 50 — 8y

Answer this question