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

don't clone if the player already has?

Asked by 6 years ago

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)
0
Do elseif not player.PlayerGui:FindFirstChild(‘aaaa’) then MaxDev_BE 55 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago
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)
0
this clones it more than once retracee 68 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

Change line 10 to:

if player.PlayerGui:FindFirstChild("aaaa") == true then
0
This should work. SBlankthorn 329 — 6y

Answer this question