GUI disappearing after button pressed for the 3rd time

OK, so whenever I press the GUI button for the 3rd time, it just disappears.
It’s a maze optimization script. Basically means it changes the map/maze every time when the button is clicked. (On the players screen not server).

Script:

script.Parent.tMaze.MouseButton1Click:Connect(function()
	game.Workspace:FindFirstChild("OriginalMaze").Parent = game.Lighting
	game.Lighting:FindFirstChild("SecondMaze").Parent = game.Workspace
	script.Parent.tMaze.Visible = false
	script.Parent.dMaze.Visible = true
	script.Parent.clicksound:Play()
end)
script.Parent.dMaze.MouseButton1Click:Connect(function()
	game.Workspace:FindFirstChild("SecondMaze").Parent = game.Lighting
	game.Lighting:FindFirstChild("OriginalMaze").Parent = game.Workspace
	script.Parent.tMaze.Visible = true
	script.Parent.dMaze.Visible = false
	script.Parent.clicksound:Play()
end)

Could you specify which gui button disappears?

tMaze or dMaze?

I’m pretty sure it’s dMaze and tMaze both.

Is the visibility of the dMaze Button changing by another script?

Nope it’s only 1 and it’s this one. ( It’s a Local script btw).

You clicking on buttons like: tMaze → dMaze → tMaze and have you errors in your output console?

Hmm… I tested the scripts

without


game.Workspace:FindFirstChild("OriginalMaze").Parent = game.Lighting
	game.Lighting:FindFirstChild("SecondMaze").Parent = game.Workspace

game.Workspace:FindFirstChild("SecondMaze").Parent = game.Lighting
	game.Lighting:FindFirstChild("OriginalMaze").Parent = game.Workspace

and I didn’t face any problems.

So maybe the problem happens with parenting the Mazes.

Maybe Instead of changing their parents clone them to Workspace.

1 Like
local OM = game.Workspace:FindFirstChild("OriginalMaze")
local SM = game.Lighting:FindFirstChild("SecondMaze")
script.Parent.tMaze.MouseButton1Click:Connect(function()
	OM.Parent = game.Lighting
	SM.Parent = game.Workspace
	script.Parent.tMaze.Visible = false
	script.Parent.dMaze.Visible = true
	script.Parent.clicksound:Play()
end)
script.Parent.dMaze.MouseButton1Click:Connect(function()
	SM.Parent = game.Lighting
	OM.Parent = game.Workspace
	script.Parent.tMaze.Visible = true
	script.Parent.dMaze.Visible = false
	script.Parent.clicksound:Play()
end)

And i rec you make like this for not searching those mazes in workspace

Never mind, it was my fault lol. Turns out the tMaze’s transparency was set to 1. Therefore I couldn’t see it. I sincerely apologize for my stupidity. Thanks for helping though! :blush:

3 Likes

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