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

Boolean value keeps changing from false to true, and back again?

Asked by 2 years ago

Problem: The code is for a round system, and has a variable which is used to determine if there are enough players in the game. The variable uses two other variables, the amount of players in the game and the minimum number of players needed to start a round, and makes sure the amount of players is greater than or equal to the minimum number of players needed. Since the minimum number of players is set to 2, when only one person joins the variable will correctly print "false". However, when there are 2 players, it keeps printing "true" and "false", and keeps printing that.

Solutions tried so far: There were no devforum topics about this. A solution that was attempted was to move the variables outside of the player added event on the script, but instead it kept printing false instead, even when there were 2 people.

Code (Is a Script):

01--Variables
02local ServerScriptService = game:GetService("ServerScriptService")
03local runService = game:GetService("RunService")
04local players = game:GetService("Players")
05local replicatedStorage = game:GetService("ReplicatedStorage")
06local events = replicatedStorage:WaitForChild("Events")
07local roundEvent = events:WaitForChild("RoundEvent")
08local StatusEvent = events:WaitForChild("StatusEvent")
09local values = replicatedStorage:WaitForChild("Values")
10local ServerModules = ServerScriptService:WaitForChild("Modules")
11local Maps = require(replicatedStorage:WaitForChild("Modules"):WaitForChild("MapsModule"))
12local VoteFunction = replicatedStorage:WaitForChild("Events"):WaitForChild("VoteFunction")
13 
14--Values
15local intermissionTime = 1
View all 95 lines...

tanks for taking time - boxy

Answer this question