Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

PopUpGui open only one? Want open many times, how fix?

hello all! im have one problem. PopUp can open frame only one? To open many times. How fix one to many times?

Open PopUpGui:

local popUp = script.Parent.PopUpGui
script.Parent.Touched:Connect(function(hit)
	if hit.Parent and game.Players:FindFirstChild(hit.Parent.Name) then
		local plr = game.Players[hit.Parent.Name]
	if plr:FindFirstChild("PlayerGui") and not plr.PlayerGui:FindFirstChild(popUp.Name) then
			popUp:Clone().Parent = plr.PlayerGui
end
end
end)

Close PopUpGui:

buttonclose = script.Parent
frame = buttonclose.Parent

function onClicked(popUp)
	frame:remove()
end
script.Parent.MouseButton1Click:Connect(onClicked)

1 comment

1

I would assume you're using a ServerScript to open the gui? And if you create an instance with a ServerScript, then destroy it with a LocalScript, the server can't see it

1 answer

✓ Accepted answer

Alright so the main issue I see here is the :destroy() command. I don't think you understand what this does, when you use the Destroy function, it removes it from the game entirely. I would recommend doing this instead. Here's a page that explains the Destroy command.

Open/Close Gui Script

This goes into a local script inside of the gui button. This will open and close the GUI without destroying it. Hope this helps.

--Made By MillerrIAm--
----Variables
buttonclose = script.Parent
frame = buttonclose.Parent
----Main Script
script.Parent.MouseButton1Click:Connect(function()
	if frame.Visible == false then
		frame.Visible = true
	else
		frame.Visible = false
end)

If this answers your question, please make sure to mark it as the answer/solution!

This discussion is preserved as it was. New answers, comments, and votes are closed.