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)
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)
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.
2 comments
Add "if not plr.PlayerGui:FindFirstChild("StoreGui") then" into line 2 and close it off in line 4 with "end"
Thanks dude, That helps, I'm just focused on so much other stuff for my game that i forgot how to do it