Hi, I’m trying to make a turn based game, similar to Civilization series mechanics. However, I’m not too clear on the logic path of trying to make one, and instead I made a primitive system of my idea which still doesn’t work. Perhaps anyone can guide me on trying to make such a system? Mind you, I’m not too good with tables if the system requires it, so I’ll try my best to keep up.
Here’s my script and I’m ready to face every sort of criticism for this haha:
local RS = game.ReplicatedStorage
local TurnFolder = RS.TurnSystem
local EVENT = RS.Turn
local Team = TurnFolder.TurnTeam
EVENT.OnServerEvent:Connect(function(PLAYER, TEAM) -- if someone presses next round button
if TEAM == "Blue" then
Team.Value = "Red"
else
if TEAM == "Red" then
Team.Value = "Yellow"
else
if TEAM== "Yellow" then
Team.Value = "Blue"
end
end
end
end)
Team.Changed:Connect(function() -- this is the issue. It's the check whether if there are no players in the team, which will make the game skip the team
local Teams = game:GetService("Teams"):GetTeams()
for _, team in pairs(Teams) do
local players = team:GetPlayers()
if #players == 0 then
print(team.Name .. " has no players")
if team.Name == "Blue" then
Team.Value = "Red"
wait(1)
else
if team.Name == "Red" then
Team.Value = "Yellow"
wait(1)
else
if team.Name == "Yellow" then
Team.Value = "Blue"
wait(1)
end
end
end
end
end
end)