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

don't clone if the player already has?

i want to make this script where if the player already has this gui in it's playergui then don't clone it, but if the player doesn't then you do clone it. But this script doesn't work.

local debounce = false
local Players = game:GetService("Players")
local storage = game:GetService("ServerStorage")
local aaaa = storage.aaaa
script.Parent.Touched:Connect(function(hit)
	
	
	
	local player = Players:GetPlayerFromCharacter(hit.Parent)
	if player.PlayerGui.aaaa then
		print("already has")
		
	else
	if not debounce then
		debounce = true
	aaaa:Clone().Parent = player.PlayerGui
	print("cloned gui")
	wait(99999999999999999999999999999999999999999999999999999999999999999999)
	
	debounce = false
	end
	end
	
end)

1 comment

0

Do elseif not player.PlayerGui:FindFirstChild(‘aaaa’) then

2 answers

local debounce = false
local Players = game:GetService("Players")
local storage = game:GetService("ServerStorage")
local aaaa = storage.aaaa
script.Parent.Touched:Connect(function(hit)



    local player = Players:GetPlayerFromCharacter(hit.Parent)
    local guicheck = player.PlayerGui:FindFirstChild(aaaa)
    if guicheck then
        print("already has")

    else

    aaaa:Clone().Parent = player.PlayerGui
    print("cloned gui")

    end
    end

end)

1 comment

0

this clones it more than once

Change line 10 to:

if player.PlayerGui:FindFirstChild("aaaa") == true then

1 comment

0

This should work.

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