local banDS = game:GetService("DataStoreService"):GetDataStore("Bans") local mods = {} local admins = {476564429} game:GetService("Players").PlayerAdded:Connect(function(plr) local key = "-Banned" .. plr.UserId local success, val = pcall(function() return banDS:GetAsync(key) end) if(success) then if(val) then if(val[2] == true) then plr:Kick("\n You have been permanently banned. \n Reason: \n" .. val[1]) end end else print("error" .. plr.UserId .. " " .. plr.Name) warn(val) end end) game:GetService("ReplicatedStorage").WarnRequest.OnServerEvent:Connect(function(plr, reason) local text = game.Players[plr].Character.Head.Overhead.Warnings.Text local wrnings = game.Players[plr].Character.Head.Overhead.Warnings local amt = game.Players[plr].Warnings amt.Value = amt.Value + 1 text = "W" .. amt.Value .. " - " .. reason if amt.Value >= 3 then game.Players[plr]:Kick("You've reached the maximum number of warnings and have been kicked from the server.") end end) game:GetService("ReplicatedStorage").BanRequest.OnServerEvent:Connect(function(mod, plr, reason) if(table.find(mods, mod.UserId)) then if not plr.UserId == admins then local key = "-Banned" .. plr.UserId local success, err = pcall(function() banDS:SetAsync(key, {reason, true}) end) plr:Kick("\n You have been permanently banned. \n Reason: \n" .. reason) end end end) game:GetService("ReplicatedStorage").UnbanRequest.OnServerEvent:Connect(function(mod, plr, reason) if(table.find(mods, mod.UserId)) then local key = "-Banned" .. plr.UserId local success, err =pcall(function() banDS:SetAsync(key, {reason, false}) end) end end) game:GetService("ReplicatedStorage").KickRequest.OnServerEvent:Connect(function(mod, plr, reason) if(table.find(mods, mod.UserId)) then if not plr.UserId == admins then plr:Kick("\n You are kicked from this server. \n Reason: \n " .. reason) end end end)
Now, i got the attempt to concatenate string with Instance error on line 26. Script now:
local banDS = game:GetService("DataStoreService"):GetDataStore("Bans") local mods = {} local admins = {476564429} game:GetService("Players").PlayerAdded:Connect(function(plr) local key = "-Banned" .. plr.UserId local success, val = pcall(function() return banDS:GetAsync(key) end) if(success) then if(val) then if(val[2] == true) then plr:Kick("\n You have been permanently banned. \n Reason: \n" .. val[1]) end end else print("error" .. plr.UserId .. " " .. plr.Name) warn(val) end end) game:GetService("ReplicatedStorage").WarnRequest.OnServerEvent:Connect(function(plr, reason) local text = plr.Character.Head.Overhead.Warnings.Text local wrnings = plr.Character.Head.Overhead.Warnings local amt = plr.Warnings amt.Value = amt.Value + 1 text = "Warning " .. amt.Value .. ": Reason:" .. reason if amt.Value >= 3 then plr:Kick("You've reached the maximum number of warnings and have been kicked from the server.") end end) game:GetService("ReplicatedStorage").BanRequest.OnServerEvent:Connect(function(mod, plr, reason) if(table.find(mods, mod.UserId)) then if not plr.UserId == admins then local key = "-Banned" .. plr.UserId local success, err = pcall(function() banDS:SetAsync(key, {reason, true}) end) plr:Kick("\n You have been permanently banned. \n Reason: \n" .. reason) end end end) game:GetService("ReplicatedStorage").UnbanRequest.OnServerEvent:Connect(function(mod, plr, reason) if(table.find(mods, mod.UserId)) then local key = "-Banned" .. plr.UserId local success, err =pcall(function() banDS:SetAsync(key, {reason, false}) end) end end) game:GetService("ReplicatedStorage").KickRequest.OnServerEvent:Connect(function(mod, plr, reason) if(table.find(mods, mod.UserId)) then if not plr.UserId == admins then plr:Kick("\n You are kicked from this server. \n Reason: \n " .. reason) end end end)
OnServerEvent
event gives you the player instance as the first argument, you don't need to do Players[plr]
to get the instance, plr
is already the player instance itself. You are trying to index Players
with an instance and that's why you get the error. You can fix the line and others to:
local text = plr.Character.Head.Overhead.Warnings.Text