Hello Everyone!
To see if my script for cloning a tool to every player's backpack was working, I edited the for loop that puts a sword into the player's backpack to see what my "player" variable was referencing to (I'm still learning to code. I also included other for loops nested in a while true do loop in the code snippet to see if it had the problem had to do with this problem).
Main = require(game.Workspace.ModuleScripts.Main)
local status = game.ReplicatedStorage:WaitForChild("Status")
local intermissionTime = 3
local roundTime = 120
local players = game.Players:GetPlayers()
local playerService = game:GetService("Players")
local Number = intermissionTime
local sword = game:GetService("ReplicatedStorage").Swords.BasicSword
while true do
for i = 1, intermissionTime, 1 do
status.Value = "INTERMISSION (" .. Number .. ")"
wait(1)
Number = Number - 1
end
Number = roundTime
Main.ToBattleMap()
for i = 1, #players, 1 do -- for loop that is completely ignored
player = players[i]
print(player.Parent)
end
for i = 1, roundTime, 1 do
status.Value = "ROUND IN PROGRESS (" .. Number .. ")"
wait(1)
Number = Number - 1
end
Main.ToLobbyMap()
Number = intermissionTime
end
When I went to test it out, it didn't print anything, but the last for loop worked. Can someone please tell me why this is happening and how to fix it?
Thanks in advance :)

1 comment
To make this easier to analyze do you mind simplifying the script by instead reassigning variables like local intermission time is 3 but say intermission time is equal to a new variable. Can you keep it as one to make it simpler please?