So I have a clickdetector that clones the gui to playergui +++

But when I close it and press the block its clones the GUI again. As I mentioned the click detector clones the GUI so is there any way I can open it again without cloning it again at the same time. Also the GUI Is in the workspace.

Or how can I reparent the GUI to the PlayerGui with a script when I pressed a button. Sorry its a bit complicated for as I’m new at LUA Scripting.

when the user clicks the clickdetector, check if the playergui already contains that gui and if so, just make teh frame visible.

(you can access a screengui in playergui if it was cloned and parented from the server)

How do I do that script? I know how to do If statements but how to the script though?

clickdetector.mouseclick (player)
if player.PlayerGui:FindFirstChild(yourGui.Name) then
player.PlayerGui[yourGui.Name].Frame.Visible = true
else
yourGui:Clone().Parent = player.PlayerGui
end
end)

thats just some half-not pseudocode

1 Like

Alright Il try right, Il test it right now!

1 Like

whhat is an pseudocode? Sorry I dont know

it’s basically just like an informal way to explain an algorithm so it basically looks written in english and helps you to understand the steps to writing code but it isnt actual code

2 Likes

I cant press the button no more after closing the gui


for i,v in pairs(model:GetDescendants()) do
	print(v.Name)
	if v:IsA("ClickDetector") then
		print("Step1")
		v.MouseClick:connect(function(player)
			if player.PlayerGui:FindFirstChild("SCIGui") then
				player.PlayerGui["SCIGui"].Backround.Visible = true
			else 
				gui:Clone().Parent = player.PlayerGui
			end
		end)
	end
end

you spelled Background wrong

[limit]

1 Like

Oh thats the name of frame. :sweat_smile::sweat_smile:

oh lord haha

well, can you show me the code for what hides the gui?

Im at mobile right now but this is the code:

 Close.MouseButton1Click:Connect(function()
gui.visible = false
 end — it works but I can’t open the gui again after closing it.

and what is ‘gui’

just wait till ur on pc and reply again later

gui is a variable I made or its the frame but in a variable

So I fixed it!

So the problem was that we are making the frame visible for all players in a server script so I made a Remote Event thats runs from the server to local script and it worked perfectly.

local function OpenGui()
	player.PlayerGui:WaitForChild("SCIGui").Backround.Visible = true
end 
game.Workspace.ShranksSCI.OpenGUI.OnClientEvent:Connect(OpenGui)
for i,v in pairs(model:GetDescendants()) do
	print(v.Name)
	if v:IsA("ClickDetector") then
		print("Step1")
		v.MouseClick:connect(function(player)
			if player.PlayerGui:FindFirstChild("SCIGui") then
				script.Parent.OpenGUI:FireAllClients()
			else
				gui:Clone().Parent = player.PlayerGui
			end
		end)
		
	end
end

Still, Thank you for helping me!