Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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
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 Spjureeedd 385 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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!

Ad

Answer this question