Images Aren't Updating According To The If Statement? (Clueless)

Hi all, for some reason my images aren’t updating in the if statement when my saved values say they should.

Client

if found == true then 
			--Make images visible
			if script.Parent.FoundCrystal.Crystalframe.Scroll[v.Name].Visible == false then
				script.Parent.FoundCrystal.Crystalframe.Scroll[v.Name].Visible = true
				local save = game.ReplicatedStorage.ClientToServer:WaitForChild("SaveVis")
				save:FireServer(v.Name)
				local mystName = string.sub(v.Name, 1, (string.len(v.Name) - 5))
				script.Parent.FoundCrystal.Crystalframe.Scroll[mystName].Visible = false
				local savenonvis = game.ReplicatedStorage.ClientToServer:WaitForChild("NonVis")
				savenonvis:FireServer(mystName)
				--Turns visible off for mystery; play sound
				-- Communicate with server 
				local PlayerData = game:GetService("Players").LocalPlayer:WaitForChild("PlayerData")
				local foundvalue = PlayerData:FindFirstChild("SaveImage"):FindFirstChild(v.Name)
				local notfoundvalue = PlayerData:FindFirstChild("SaveImage"):FindFirstChild(mystName)
				-- Make images visible depending on bool value
				if foundvalue ~= nil and notfoundvalue ~= nil then
					script.Parent.FoundCrystal.Crystalframe:FindFirstChild("Scroll")[v.Name].Visible = true
					script.Parent.FoundCrystal.Crystalframe:FindFirstChild("Scroll")[mystName].Visible = false
				else 
					script.Parent.FoundCrystal.Crystalframe:FindFirstChild("Scroll")[v.Name].Visible = false
script.Parent.FoundCrystal.Crystalframe:FindFirstChild("Scroll")[mystName].Visible = true

end

Server

local save = game.ReplicatedStorage.ClientToServer:WaitForChild("SaveVis")
local savenonvis = game.ReplicatedStorage.ClientToServer:WaitForChild("NonVis")


-- To keep the visible ones visible (top)
save.OnServerEvent:Connect(function(plr,hamburger)
	local pdata = plr:FindFirstChild("PlayerData"):FindFirstChild("SaveImage")
	local visvalue = Instance.new("BoolValue",pdata)
	visvalue.Value = true
	visvalue.Name = hamburger
end)

-- To keep the non visible ones non visible (bottom)
savenonvis.OnServerEvent:Connect(function(plr,mystName)
	local pdata = plr:FindFirstChild("PlayerData"):FindFirstChild("SaveImage")
	local nonvalue = Instance.new("BoolValue",pdata)
	nonvalue.Value = false
	nonvalue.Name = mystName
end)

Help is appreciated, thanks!

you are talking about this if statement?

1 Like

Yes, indeed I am. I am talking about that if statement.

To clarify, everything above this variable works as intentioned.

local PlayerData = game:GetService("Players").LocalPlayer:WaitForChild("PlayerData")

Try to print foundvalue and notfoundvalue to check what it exactly is. Sometimes it is something else

1 Like

it happend to me as well when i thought it was something then once i printed it, it was something else

1 Like

Could be

if foundvalue == nil and notfoundvalue ~= nil then
1 Like

Like this right?

	print(notfoundvalue)

Or

				print("notfoundvalue")

yes and the same with foundvalue (After your 2 variables ofc)

1 Like

Yep, so first option right? Yeah?

notfoundvalue, not “notfoundvalue”. the difference is between these “” it will print the word notfoundvalue

1 Like

Okay, so it’s printing both, weirdly …

which line it is? nil or bunny?

1 Like

It is printing nil first for each “print” then a few seconds later it is printing “bunnyx” as wanted for each print.

so basically what you mean is, it loops with a for loop through your code 2 times. The first time it prints nil and the second time it prints bunny just before this line?

1 Like

Yes, that is absolutely correct .

Here is the rest of my script btw, not sure if it helps tho

--Found Script
local FoundRegions = game.Workspace:WaitForChild("FoundRegions")

local found = false

while wait(1) do
	for i, v in pairs(FoundRegions:GetChildren()) do
		
		found = false
		local region = Region3.new (v.Position - (v.Size/2),v.Position + (v.Size/2))
		local parts = game.Workspace:FindPartsInRegion3WithWhiteList(region, game.Players.LocalPlayer.Character:GetDescendants())
		
		for _, part in pairs(parts) do
			--Loop one by one through part table
			if part:FindFirstAncestor(game.Players.LocalPlayer.Name) then
				--Print "Player was found"
				found = true
				break 
			else
				found = false
				--Print "Player was not found in region"				
			end
		end

So, i think this won’t work but just to be sure try to replace:

by

1 Like

i mean’t

Sorry i mistook it :+1:

1 Like

Unfortunately it doesn’t work I’m afraid.