When i try to turn my values into strings it returns nil

so i have a logs system and it tells you what value has changed and what it changed to.

Like for example if i changed a value from true to fale, the new log should say
“Changed MyValue To: False”

the reason im trying to turn a bool into a string is because well… you cant put a bool as text on gui.
One issue is that it just always returns nil, even if the value that changed was a string value.

Heres the code that check everything:

local function CreateUpdateLog()
	local LS = game.Workspace:WaitForChild("LogsScreen"):WaitForChild("SurfaceGui"):WaitForChild("BG")
	
	
	local L1 = LS.TEMP.About:Clone()
	L1.About.Text = "Heres some things we changed!"
	L1.Parent = LS.About
	L1.Visible = true
	
	local L2 = LS.TEMP.Date:Clone()
	L2.Date.Text = module.Date
	L2.Parent = LS.Date
	L2.Visible = true
	
	
	--Complicated stuff :(
	local L3 = LS.TEMP.Info:Clone()
	L3.Parent = LS.Info
	local Placement = L3.List
	local Item = LS.TEMP.ChangedLabel
	L3.Visible = true
	
	
	for i, v in LastInstanceOfWRLDDATA do
		if v ~= module[table.find(module, i)] then
			local L4 = Item:Clone()
			L4.Text = "Changed "..i.."To: "..tostring(module[table.find(module, i)])
			L4.Parent = Placement
			L4.Visible = true
		end
	end
	
	for _, V in module do
		if _ == "Age" or  _ == "Pop" or _ == "Date" or _ == "Danger" or _ == "Economy" or _ == "AvrgMood" or _ == "Wants" or _ == "Anger" then
			LastInstanceOfWRLDDATA[_] = V
		end
	end
	
	
end

And heres what it does right now:

If anyone can help, thanks!

tostring always returns nil could be due to the way you are accessing the elements in LastInstanceOfWRLDDATA and module.

local function CreateUpdateLog()
    local LS = game.Workspace:WaitForChild("LogsScreen"):WaitForChild("SurfaceGui"):WaitForChild("BG")
    
    local L1 = LS.TEMP.About:Clone()
    L1.About.Text = "Heres some things we changed!"
    L1.Parent = LS.About
    L1.Visible = true
    
    local L2 = LS.TEMP.Date:Clone()
    L2.Date.Text = module.Date
    L2.Parent = LS.Date
    L2.Visible = true
    
    -- Complicated stuff :(
    local L3 = LS.TEMP.Info:Clone()
    L3.Parent = LS.Info
    local Placement = L3.List
    local Item = LS.TEMP.ChangedLabel
    L3.Visible = true
    
    for key, oldValue in pairs(LastInstanceOfWRLDDATA) do
        local newValue = module[key]
        if newValue ~= oldValue then
            local L4 = Item:Clone()
            L4.Text = "Changed "..key.." To: "..tostring(newValue)
            L4.Parent = Placement
            L4.Visible = true
        end
    end
    
    for key, value in pairs(module) do
        if key == "Age" or key == "Pop" or key == "Date" or key == "Danger" or key == "Economy" or key == "AvrgMood" or key == "Wants" or key == "Anger" then
            LastInstanceOfWRLDDATA[key] = value
        end
    end
end

that works, thank you! now i just gotta fix it so it wont make a log if no new info exists

1 Like

one issue: idk how to do that with your code…
could you help with that?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.