✓ Accepted answer
Let's "unroll" the for loop. For loops just do something once per thing in the container. So your code is currently equivalent to
do
local v = "NiniBlackJackQc"
if player.Name == v or player.UserId == game.CreatorId then
script.Parent:Destroy()
GameSound()
print("Administrator: "..player.Name, "Administrator Id: "..player.UserId)
return;
else
Character:Destroy()
Instance.new("BlurEffect",workspace.CurrentCamera)
IntroSound()
print("Player: "..player.Name, "Player Id: "..player.UserId)
return;
end
end
do
local v = "DAHUI84"
if player.Name == v or player.UserId == game.CreatorId then
script.Parent:Destroy()
GameSound()
print("Administrator: "..player.Name, "Administrator Id: "..player.UserId)
return;
else
Character:Destroy()
Instance.new("BlurEffect",workspace.CurrentCamera)
IntroSound()
print("Player: "..player.Name, "Player Id: "..player.UserId)
return;
end
end
Notice that you're never going to get passed the first loop: you unconditionally return having made a decision based on only the first name in the list.
Here is the code you meant to write. We can define isAuthorized later:
local Authorization = {"NiniBlackJackQc","DAHUI84"}
local player = game:GetService("Players").LocalPlayer
repeat wait() until player.Character
local Character = player.Character
if isAuthorized() then
script.Parent:Destroy()
GameSound()
print("Administrator: "..player.Name, "Administrator Id: "..player.UserId)
else
Character:Destroy()
Instance.new("BlurEffect",workspace.CurrentCamera)
IntroSound()
print("Player: "..player.Name, "Player Id: "..player.UserId)
end
This clearly doesn't have logic bugs, because it says to do exactly what you want (notice that since there's no more code there's no need for returns either)
isAuthorized is simple:
function isAuthorized()
if player.UserId == game.CreatorId then
return true
end
for _, name in pairs(Authorization) do
if name == player.Name then
return true
end
end
end
1 comment
i think line 8 should be "if Authorization then"