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
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
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
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
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