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

How do I delete an object?

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.

1 comment

0

Bumppp

1 answer

✓ Accepted answer

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.

2 comments

0

p.s math.huge is always infinite so it should never stop doing the loop also keep the wait so you dont crash.

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?

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