Visible property is only assigned once

Hello! My name is BrawlStarsLover14 and I’ve been working the past 1-2 months at an project, whitch
is trying to recreate roblox. Everything is pleasing me, but this random glitch is just making me worried.

local DataStoreService = game:GetService("DataStoreService")
local PopularDataStore = DataStoreService:GetOrderedDataStore("GameVisits2")
local GamesDataStore = DataStoreService:GetDataStore("GamesData","Testing14")
local PopularFrame = script.Parent.PopularFrame
local RecomendedFrame = script.Parent.RecomendedFrame
local GameFrame = script.Parent.Parent.GameFrame

function DoPopularList()
	for _,Child in ipairs(PopularFrame:GetChildren()) do if Child:IsA("TextButton") then Child:Destroy() end end
	local Pages = PopularDataStore:GetSortedAsync(false,20)
	local Page = Pages:GetCurrentPage()
	for _,Data in ipairs(Page) do
		local GameId = Data.key - 1
		local succes,GameData = pcall(function()
			return GamesDataStore:GetAsync("Data") or {}
	   end)
		if not succes then
			warn(GameData)
			return
		end
		GameData = GameData[GameId]
		GameData = game.HttpService:JSONDecode(GameData)
		local GameButton = Instance.new("TextButton")
		GameButton.Size = UDim2.new(0, 113,0, 120)
		GameButton.BackgroundTransparency = 1
		GameButton.BorderSizePixel = 0
		GameButton.Text = ""
		GameButton.Parent = PopularFrame
		local GameImage = Instance.new("ImageLabel")
		GameImage.Size = UDim2.new(0,113,0,80)
		GameImage.BackgroundTransparency = 0
		GameImage.BorderSizePixel = 0
        GameImage.Parent = GameButton
	    GameImage.Image = "https://assetgame.roblox.com/asset/?id="..tostring(GameData.GameImage)
	    local GameName = Instance.new("TextLabel")
		GameName.BackgroundTransparency = 0
		GameName.Text = GameData.GameName
		GameName.BorderSizePixel = 0
		GameName.TextScaled = true
		GameName.Size = UDim2.new(0,113,0,30)
		GameName.Position = UDim2.new(0,0,0,80)
		GameName.Parent = GameButton
		
		GameButton.MouseButton1Click:Connect(function()
			GameFrame.Visible = true
			GameFrame.GameId.Value = GameId
			GameFrame.GameDescription.Text = GameData.GameDescription
			GameFrame.GameName.Text = GameData.GameName
			GameFrame.GameImage.Image = "https://assetgame.roblox.com/asset/?id="..tostring(GameData.GameImage)
			script.Parent.Visible = false
			warn("OK")
		end)
	end
end

function DoRecomendedList()
	for _,Child in ipairs(RecomendedFrame:GetChildren()) do if Child:IsA("TextButton") then Child:Destroy() end end
	local GamesData = GamesDataStore:GetAsync("Data") or {}
	for _,Data in ipairs(GamesData) do
		local GameId = Data.GameId
		local GameButton = script.TextButton:Clone()
		GameButton.Text = ""
		local GameImage = GameButton.ImageLabel
	    GameImage.Image = Data.GameImage
	    local GameName = GameButton.TextLabel
		GameName.Text = Data.GameName
        local GlobalGameId = GameButton.Value
        GlobalGameId.Value = GameId
        GameButton.Parent = RecomendedFrame

        GameButton.GameImage.Value = Data.GameImage
        GameButton.GameDescription.Value = Data.GameDescription
        GameButton.GameName.Value = Data.GameName
	end
end

coroutine.wrap(function()
	while wait(1) do
		script.Parent.PopularFrame.Position = script.Parent.PopularFrame.Position + UDim2.new(0,0,0,1)
		wait(0.000001)
		script.Parent.PopularFrame.Position = script.Parent.PopularFrame.Position - UDim2.new(0,0,0,1)
	end
end)()

DoPopularList()
--DoRecomendedList()

If you din’t saw in the script (I don’t see anything wrong :upside_down_face:), this Mouse event part is broken:

		GameButton.MouseButton1Click:Connect(function()
			GameFrame.Visible = true
			GameFrame.GameId.Value = GameId
			GameFrame.GameDescription.Text = GameData.GameDescription
			GameFrame.GameName.Text = GameData.GameName
			GameFrame.GameImage.Image = "https://assetgame.roblox.com/asset/?id="..tostring(GameData.GameImage)
			script.Parent.Visible = false
			warn("OK")
		end)

So, always when I press OK gets warned, but the GameFrame only gets Visible to true the first time pressed. So, it only gets Visible to true one time and Ok is always pressed. The Button Connection is fine, the visibility is bad

1 Like

Note that this is a Script, if no response I will try to make a RemoteEvent to close it/open it.

Never mind, I changed that broken part into an RemoteEvent for an LocalScript to take care of the Information given.