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

How do i stop the gui from cloning?

Asked by
sad_eyez 162
8 years ago

Okay so what I wanna know is how can I make this gui not get cloned if the player already has it.

script.Parent.MouseClick:connect(function(plr)
    local gui = script.Parent.StoreGui:Clone()
    gui.Parent = plr.PlayerGui
end)
1
Add "if not plr.PlayerGui:FindFirstChild("StoreGui") then" into line 2 and close it off in line 4 with "end" Vrakos 109 — 8y
0
Thanks dude, That helps, I'm just focused on so much other stuff for my game that i forgot how to do it sad_eyez 162 — 8y

1 answer

Log in to vote
1
Answered by
Sublimus 992 Moderation Voter
8 years ago

You can use :findFirstChild to check and see if the gui already exists.

script.Parent.MouseClick:connect(function(plr)
    if not (plr.PlayerGui:findFirstChild("StoreGui")) then  -- If the playerGui doesn't contain a storegui already.
        local gui = script.Parent.StoreGui:Clone()
        gui.Parent = plr.PlayerGui
    end
end)
Ad

Answer this question