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

How do I delete an object?

Asked by 7 years ago
Edited 7 years ago

Hey I know this sounds dumb but I'm knew to this programming thing, so don't judge lol.

My question is, how do I make a script that would loop (INFINITELY) delete the object that is called ClassGui in every player's PlayerGui folder? Not just one player, ALL players.

0
Bumppp SambaLover 16 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

u would loop ipairs which looks into every players inventory

example

for i=1, math.huge do
wait()
    for i,v in ipairs(game.Players:GetChildren()) do
        if v:FindFirstChild('PlayerGui') then
            if v.PlayerGui:FindFirstChild('ClassGui') then
                v.PlayerGui.ClassGui:Destroy()
            end
        end
    end
end

i, v pairs mean index, variable pairs. In this case the index is game.Players so it is searching for variables of the index i.e. all the children of game.Players. After that just kind of verify that the variable in players is a player by looking for PlayerGui then verify they have ClassGui then destroy ClassGui if they have it.

0
p.s math.huge is always infinite so it should never stop doing the loop also keep the wait so you dont crash. MrDefaultMan 113 — 7y
0
One more thing sorry, what would I change in this script if there were children in between PlayerGui and ClassGui? The script works great until I put children in between the two, what should I change in the script to fix this? SambaLover 16 — 7y
Ad

Answer this question