Hello fellow scripters.
I am currently making an admin panel for my game, and so far I have kick, kill, broadcast and shutdown events working. I also have a ban event but that does not seem to be working? This is the reason I am here.
I have a GUI, well, It's better to show you.
https://www.youtube.com/watch?v=eF5is-kjddQ So, as it shows in the video, the kick script works but not the ban script.
Here is the ban script:
function script.Parent.OnServerInvoke(player, Data) local Target = Data[1] local Reason = Data[2] local Player = game.Players:FindFirstChild(Target) local HasPlayer = not Player == nil local HasReason = not string.len(Reason) == 0 local DataStore = game:GetService("DataStoreService"):GetDataStore("motfAdminPanel") local ID = nil if HasPlayer then ID = Player.UserId for _,v in next, _G.immuneToBan do if v == ID then return "exempt" end end if HasReason then Player:Kick("You have been banned."); else Player:Kick("You have been banned for the following reason: " .. Reason) end end if ID == nil then local success = pcall(function() ID = game.Players:GetUserIdFromNameAsync(Target) end) if not success then return "noplayer" end end for _,v in next, _G.immuneToBan do if v == ID then return "exempt" end end if ID < 0 then return "guest" end if HasReason then DataStore:SetAsync(ID, Reason) else DataStore:SetAsync(ID, 1); end return "banned" end
And if it's required, here is the kick script:
function script.Parent.OnServerInvoke(player, Data) local Target = Data[1] local Reason = Data[2] local Player = game.Players:FindFirstChild(Target) if Player == nil then return false end if string.len(Reason) == 0 then Player:Kick("You have been kicked."); else Player:Kick("You have been kicked for the following reason: " .. Reason) end return true end
These are all in events, as shown in this picture: https://imgur.com/GFudgvE
I would really appreciate help. Thanks, guys!