Hello, there I am making a auto team changer when the InGame Value = True.
There is also a countdown and I am trying to figure this out, I have tried to use this funtion but it doesn’t seem to work although when I print something it woks just fine.
local InGame = game.Workspace.MainSystem.InGame.Value
local status = game.workspace.MainSystem.GuiStat
local rTeam = game.Teams.Red
local bTeam = game.Teams.Blue
local players = game.Players:GetPlayers() --returns a table of all the players in-game
local function teamUp() --Funtion to Change Team
for i, v in pairs(players) do --loop through table
if i % 2 == 0 then --if even number
print("H") --Even
else
print("M") --blue team
end
end
end
while true do
while InGame == false and status.Value > 0 do --Intermission since InGame is False
wait(1)
status.Value = status.Value - 1
end
if status.Value == 0 then
InGame = true
status.Value = 10
end
while InGame == true and status.Value > 0 do --Game in progress since InGame is True
wait(1)
status.Value = status.Value - 1 --Countdown
if InGame == true then
print("Hello")
teamUp()
end
end
end
If you have any questions please reply! Thanks I am excited to get my first game out there!
I’m not sure what the problem is other than “doesn’t seem to work” - are there any details more specific?
Is the value of InGame meant to always be true as that’s how it currently seems tor read?
(And do you realise that taking the value directly on line 1 means that it won’t update with the changes of the value object?)
Ok, I was saying the script wouldn’t take into account any changes to that value object.
Have you tried using the Debugger to step through the code to see which branches are taken and then working back to work out why it has taken the wrong branch?
Try this code. EDIT: REUSE THE CODE, HAD TO FIX SOMETHING
local InGame = game.Workspace.MainSystem.InGame
local status = game.workspace.MainSystem.GuiStat
local rTeam = game.Teams.Red
local bTeam = game.Teams.Blue
local players = game.Players:GetPlayers() --returns a table of all the players in-game
local function teamUp() --Funtion to Change Team
for i, v in pairs(players) do --loop through table
if i % 2 == 0 then --if even number
print("H") --Even
else
print("M") --blue team
end
end
end
while true do
while InGame.Value == false and status.Value > 0 do --Intermission since InGame is False
wait(1)
status.Value = status.Value - 1
end
if status.Value == 0 then
InGame.Value = true
status.Value = 10
end
while InGame.Value == true and status.Value > 0 do --Game in progress since InGame is True
wait(1)
status.Value = status.Value - 1 --Countdown
if InGame.Value == true then
print("Hello")
teamUp()
end
end
end