I’m working on a ban panel and I keep getting an error saying attempt to concatenate Instance with string. Here’s the code
game.ReplicatedStorage.BanOrUnbanPlayer.OnServerEvent:Connect(function(player, playerToBan, Reason, Ban)
if Ban == "Ban" then
for i,v in pairs(moderators) do
if player.UserId == v then
if game.Players:FindFirstChild(playerToBan) then
if game.Players[playerToBan].UserId ~= player.UserId then
print(playerToBan.." has been successfully banned!")
game.Players[playerToBan]:Kick("You've been banned. \n Reason: "..Reason) -- The line getting the error.
ModerationDataStore:SetAsync(game.Players[playerToBan].UserId, {true, Reason})
else print("This player is an admin")
end
else
local players = game:GetService("Players")
local Id = players:GetUserIdFromNameAsync(playerToBan)
if Id ~= player.UserId then
ModerationDataStore:SetAsync(Id, HttpService:JSONEncode({true, Reason}))
print(playerToBan.." has been banned!")
end
end
end
end
elseif Ban == "Unban" then
local players = game:GetService("Players")
local Id = players:GetUserIdFromNameAsync(playerToBan)
ModerationDataStore:RemoveAsync(Id)
print(playerToBan.." has been unbanned!")
end
end)