I have a random player chooser script and basically, it will choose a random player and give him clothes and place him on a team. It worked fine in Studio but now it's gone to shreds, nothing is working. Here is the script:
wait(0.1) local randomPlayer = game.Players:GetPlayers()[math.random(1,#game.Players:GetPlayers())] randomPlayer.TeamColor = BrickColor.new("Really black")
Any ideas on how I an fix this?
Nothing is happening in the actual game because line 2 will execute immediately when the game starts, however the player doesnt get addedd into the game that fast,so it will get nothing and the script will end, so what you can do is use a game.Players.PlayerAdded event listener and assign your player's teams in this listener
game.Players.PlayerAdded:Connect(function(plr) game.Workspace:WaitForChild(plr.Name)--this is to make sure he spawns first, this is optional local randomPlayer = game.Players:GetPlayers()[math.random(1,#game.Players:GetPlayers())] randomPlayer.TeamColor = BrickColor.new("Deep orange") end)
Try using Remote Functions.