local datastoreservice = game:GetService("DataStoreService"):GetDataStore("hidden") local allowed = {"name","name"} game.Players.PlayerAdded:Connect(function(player) for i, v in pairs(allowed) do if player.Name == v then script.KickGui:Clone().Parent = player.PlayerGui else end end end) game.ReplicatedStorage.KickPlayer.OnServerEvent:Connect(function(player, playerToKick, reason) for i, v in pairs(allowed) do if player.Name == v then game.Players:FindFirstChild(playerToKick):Kick(reason) else datastoreservice:SetAsync(player.UserId,true) player:Kick("Exploiting Remotes") end end end)
I'm trying to detect that when a player who isn't admin runs the Kick remote it will ban them from the game. When an admin fires the remote, however, it runs both statements even though their name is allowed. Without the else statement the script works fine in that it stops non-admins from kicking however I want to also ban them.
Edit: Lines 14-23 is where the issue is
It's because you're looping through a table which has multiple indexes. If one name is v while the other isn't then ofc it'll do both the if and the else.