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

How do i stop the gui from cloning?

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)

2 comments

1

Add "if not plr.PlayerGui:FindFirstChild("StoreGui") then" into line 2 and close it off in line 4 with "end"

0

Thanks dude, That helps, I'm just focused on so much other stuff for my game that i forgot how to do it

1 answer

✓ Accepted answer

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)

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