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

Why does this loop?

Asked by 10 years ago

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

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

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)

Ad
Log in to vote
0
Answered by
Xoqex 75
10 years ago

By using the "for" "do" it creates a for loop.

Answer this question