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

Player's team changes once, doesn't change again?

Asked by 6 years ago

Hi, i'm making a Juggernaut Game with my friend, and the game works, once. All of the players team get changed to sheriff and juggernaut, and the game goes on normally, but then the second round starts, when only the juggernaut gets changed, but the sheriffs don't. Is there any to fix it?

001local maps = game.ReplicatedStorage:WaitForChild("Maps")
002local juggernaut = nil
003local players = game.Players:GetPlayers()
004local revolver = game.ReplicatedStorage.Revolver
005local knife = game.ReplicatedStorage.Knife
006local allplayers = {}
007local gamestarted = false
008local juggernautplrs = game.ReplicatedStorage.Values.JuggernautPlayers
009local sheriffplrs = game.ReplicatedStorage.Values.SheriffPlayers
010local spawnspawns = game.Workspace.Spawn.Spawns:GetChildren()
011local gameending = false
012game.Players.PlayerAdded:Connect(function(plr)
013    game.ReplicatedStorage.Values.plrs.Value = game.ReplicatedStorage.Values.plrs.Value+1
014    table.insert(allplayers,plr)
015end)
View all 101 lines...
0
Tab your code correctly, this is awful to read Vulkarin 581 — 6y
0
And as for the error, you remove juggernaut from `allplayers`  and never re-add them again. I would personally get rid of the `allplayers` table & players events, and instead at the start of every round do players:GetPlayers() instead Vulkarin 581 — 6y

Answer this question