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

Why does this loop?

This seems to loop for no reason

workspace.DescendantAdded:connect(function(a)
	if HP.CodeLock==true then
	wait(1)
	if a.ClassName=='LocalScript' or 'Script' then
		for Plr in pairs(game.Players:GetPlayers()) do
		wait(1)
		Tablet('Institutional white','ClassName ['..a.ClassName..']',Plr)
		wait(1)
		Tablet('Lime green','Disable ['..a.Name..']?',function() a.Disabled=true end,Plr)
		wait(1)
		Tablet('Lime green','Allow ['..a.Name..']?',function() a.Disabled=false end,Plr)
	end
	end
	end
end)

2 answers

✓ Accepted answer

Your check for ClassName is incorrect.

You must be explicit in comparisons

a.ClassName=='LocalScript' or a.ClassName == 'Script'

Otherwise order of operations suggest

(a.ClassName=='LocalScript') or  'Script'

which is more or less 'Script' (which will always act as true)

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