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

7 comments
there is 1 statement, so what is the problem?
there is 1 statement, so what is the problem?
sorry I meant that the else is running alongside the if statement
are you sure? try printing on both else and if statements
When I fire the remote as an admin it kicks the target but then bans me when it shouldnt. If I fire the remote from a non-admin account though it only bans me (which is how I want it to work)
Added a print to both: https://i.imgur.com/YKr9FrC.png
Try doing this but with an If Then statement.