Script mistakened boolvalue false as true

i wanted to make a gamemode system with by detecting boolvalue but however, Script was mistaking false as true, i did debug it with warn and print

image
look at this print


most of boolvalue are false

  1. Script mistaken boolvalue false as true even they are false
local filterName = workspace.system["Roblox Stuff"].Template.Term:GetChildren()
local names = {}
local towers = workspace.system["Soild Stuff"].Tower
local enabledtable = {}
-- This is where problem live here------------------------
for _, enabled in pairs(workspace.system["Roblox Stuff"].AdvancedGamemode:GetChildren()) do
	if enabled:IsA("BoolValue") then
		-- Explicitly check for both true and false
		if enabled.Value == true then
   warn(enabled.Name.." are enabled")
			table.insert(enabledtable, enabled.Name)
		else
			print(enabled.Name.." aren't enabled")
		end
	end
end
-------------------------------------------------------
-- Store all the names in an array
for _, filter in pairs(filterName) do
	table.insert(names, filter.Name)
end

And no there isn’t script that enabling them

5 Likes

Was this the full script?


Are you sure those ones are not enabled?

They aren’t getting removed from the table once they get disabled. Maybe that was the problem?

2 Likes

No. it aren’t full script, second of all
There is no script that interacting with boolvalue by turning on or off

1 Like

can you try doing a print before the if statements to make sure of the value
that is confusing tbh

if enabled:IsA("BoolValue") then
	-- Explicitly check for both true and false
	print(enabled.Name, enabled.Value)
	if enabled.Value == true then
		warn(enabled.Name.." are enabled")
		table.insert(enabledtable, enabled.Name)
	else
		print(enabled.Name.." aren't enabled")
	end
1 Like

Can you show the full script?


If you’re getting the enabled ones from the table, note that you are not removing them from the table once they get disabled.

1 Like

i paste them and it act same as mine

2 Likes

– Get all children of the ‘Term’ object

local filterName = workspace.system["Roblox Stuff"].Template.Term:GetChildren()
local names = {}
local towers = workspace.system["Soild Stuff"].Tower
local enabledtable = {}
for _, enabled in pairs(workspace.system["Roblox Stuff"].AdvancedGamemode:GetChildren()) do
	if enabled:IsA("BoolValue") then
		-- Explicitly check for both true and false
		if enabled:IsA("BoolValue") then
			-- Explicitly check for both true and false
			print("TEST :: ", enabled.Value)
			if enabled.Value == true then
				warn(enabled.Name.." are enabled")
				table.insert(enabledtable, enabled.Name)
			else
				print(enabled.Name.." aren't enabled")
			end
			end
	end
end

-- Store all the names in an array
for _, filter in pairs(filterName) do
	table.insert(names, filter.Name)
end
if enabledtable then
print(enabledtable[1].." are enabled")
-- Iterate through the names and check if they exist in the 'AdvancedGamemode' folder
for _, filter in pairs(names) do
	local GameEna2 = enabledtable[1]
if GameEna2 then
	local gameEnabled = workspace.system["Roblox Stuff"].AdvancedGamemode:FindFirstChild(GameEna2)
	if gameEnabled then
	local stringValue = gameEnabled:FindFirstChild(filter)
	if stringValue then


		-- Okay. Let's get busy tho
		if stringValue.Name == "Big" then -- Detect Value
			local Big = stringValue:FindFirstChild("Vector")
			if Big then
				if Big:IsA("Vector3Value") then
					towers.Size = Big.Value
				end
			end
		end
		if stringValue.Name == "TIme is long " then -- Time, to order Time, System.RobloxStuff.AdvancedGamemode and find value that named time
	local times = stringValue:FindFirstChild("Time")
	if times:IsA("NumberValue") then
		workspace.system["Roblox Stuff"].Values.CountDown.Value = times.Value
	end
		end
		if stringValue.Name == "No sight" then
			game.Lighting.FogEnd = 100
		end
		if stringValue.Name == "Time is shrot" then
			local times = stringValue:FindFirstChild("TIme")
			if times then
				if times:IsA("NumberValue") then
					workspace.system["Roblox Stuff"].Values.CountDown.Value = times.Value
				end
			end
		end

	else
		print("Not found: " .. filter)
	end
	end
	end
	end
else
	warn("Gamemode aren't enabled")
end
2 Likes

Could you format the code please? :slight_smile:
Add ``` before and after the code.


So far, I have no clue why it doesn’t work.

1 Like

i fixed it, Try reload. i forgot

1 Like

Could you tell me what outputs when you run this script?

for i,v in pairs(workspace.system["Roblox Stuff"].AdvancedGamemode:GetChildren()) do
   if v:IsA("BoolValue") then
      print(v.Value)
   end
end

Thanks! :slight_smile:

image

1 Like

great. image got moderated for no reason :slightly_frowning_face:

I still see it. I don’t think it was.


Now we know it’s an issue with the code you provided for sure.

What is your code mean to do? I am not really sure how it should exactly be.
Try to include as much detail as you can :slightly_smiling_face:

basically. i was making a script that detect gamemode enabled. once they are enabled. Script get them and fliter them out that gamemode don’t have any modifer, when they have modifer, script make modifer in the game. For example, if foggy pillar was enabled. script make game hard to see

uhh watch my grammar

1 Like

Could you provide two images? One of the gamemodes and one of the modifiers.

ok
Here


1 Like

For me, the part of the code that is not working for you does work for me.

Here is a script that should work:

local gamemodes = workspace.system["Roblox Stuff"].AdvancedGamemode:GetChildren()
local towers = workspace.system["Soild Stuff"].Tower
local enabledGamemodes = {}

local modifiers = {
	["Big"] = function(stringValue)
		local Big = stringValue:FindFirstChild("Vector")
		if Big then
			if Big:IsA("Vector3Value") then
				towers.Size = Big.Value
			end
		end
	end,
	["No sight"] = function()
		game.Lighting.FogEnd = 100
	end,
	["TIme is long"] = function(stringValue)
		local times = stringValue:FindFirstChild("Time")
		if times:IsA("NumberValue") then
			workspace.system["Roblox Stuff"].Values.CountDown.Value = times.Value
		end
	end,
	["Time is shrot"] = function(stringValue)
		local times = stringValue:FindFirstChild("TIme")
		if times then
			if times:IsA("NumberValue") then
				workspace.system["Roblox Stuff"].Values.CountDown.Value = times.Value
			end
		end
	end
}

for i,gamemode in gamemodes do
	if not gamemode:IsA("BoolValue") then return end
	if gamemode.Value == true then
		table.insert(enabledGamemodes, gamemode)
	end
	warn(gamemode.Name .. if gamemode.Value == true then " are enabled" else " aren't enabled")
	-- remove this warn if you want to!
end

for i, enabled in enabledGamemodes do
	for i,modifier: ValueBase? in enabled:GetChildren() do
		if modifier.Value == true and modifiers[modifier.Name] ~= nil then
			modifiers[modifier.Name](modifier)
		end
	end
end

It gets the gamemodes that are enabled, and then gets the functions of all the enabled modifiers. I also made it way more readable.

How to make a new modifier

With your old way, you would do something like this. (taken from your script)

if stringValue.Name == "Time is shrot" then
	local times = stringValue:FindFirstChild("TIme")
	if times then
		if times:IsA("NumberValue") then
			workspace.system["Roblox Stuff"].Values.CountDown.Value = times.Value
		end
	end
end

With my script, you would take the inside of the if statement:

local times = stringValue:FindFirstChild("TIme")
if times then
	if times:IsA("NumberValue") then
		workspace.system["Roblox Stuff"].Values.CountDown.Value = times.Value
	end
end

and put it inside of the table in the modifier as a function.

Example of working modifier:

["Time is shrot"] = function(stringValue) -- name of the modifier
                -- start of modifier
		local times = stringValue:FindFirstChild("TIme")
		if times then
			if times:IsA("NumberValue") then
				workspace.system["Roblox Stuff"].Values.CountDown.Value = times.Value
			end
		end
                -- end of modifier
	end

The Term folder is no longer needed!

image
techinally soulition, but this bug

How is it a bug? That was included in your original script, so I added it in.
I had this comment in the script already: