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!
