So, I have an admin GUI for my game, Today I was trying to make it work with shortened names, such as instead of "Roblox" its "Ro" for ease of use. I made a variable called "amountofplayersfound" and in my i, v loop it's supposed to see if there are either 2 or more OR 0 players found, however it can not add to the same variable until it runs again, making my "amountofplayersfound" useless if there are 2 or more players whose names start with the string.
local admins = {"iiConstable_Subwayx", "Censored_friend", "", ""}
amountofplayersfound = 0
game.Players.PlayerAdded:Connect(function(plr)
for i, v in pairs(admins) do
if plr.Name ~= v then
wait()
else
script:Clone().Parent = plr.PlayerGui
end
end
end)
local admins = {"iiConstable_Subwayx", "Censored_friend", "", ""}
game.ReplicatedStorage.Events["Censored"].OnServerEvent:Connect(function(plr, playerkick, reason)
for i, v in pairs(admins) do
if plr.name == v then
if game.Players:FindFirstChild(playerkick) then
game.Players:FindFirstChild(playerkick):Kick(reason)
elseif not game.Players:FindFirstChild(playerkick) then
for a, x in pairs(game.Players:GetChildren()) do
if x.Name:lower():find(playerkick) and string.sub(x.Name,1,string.len(playerkick)) == playerkick then
amountofplayersfound = amountofplayersfound + 1 -- This is the problem
if amountofplayersfound >= 2 or amountofplayersfound == 0 then
script.owner.RemoteEvent:FireClient(v)
wait()
else
x:Kick(reason)
amountofplayersfound = amountofplayersfound - 1
wait()
end
end
end
end
end
end
end)
