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

How do i make the script detect if something exists???

Asked by 5 years ago

So I wanted to make some sort of script that detects if a gui exist or not but I don't know what I should do. can someone help?

if script.Addon == true then
script.Addon.Parent = game.StarterGui
else
script.Parent:Destroy()
end

1 answer

Log in to vote
1
Answered by
yHasteeD 1819 Moderation Voter
5 years ago
Edited 5 years ago

use :FindFirstChild("ITEM NAME") here is a wiki page of FindFirstChild: Wiki - FindFirstChild

Here is your Fixed Script.

if script:FindFirstChild("Addon") then
    script.Addon.Parent = game.StarterGui -- This not send for all players, you need to send to PlayerGui.
else
    script.Parent:Destroy()
    wait(3) -- For no errors on remove the item.
end

Hope it helped :D

Ad

Answer this question