How would I make a system like this?
I have 3 values that are sent to a event, Time, Reason, Name.
How would I make a time ban system with this?
1 Like
I did that but when I tested it (out of studio) it only kicked me?
local dss = game:GetService("DataStoreService")
local bds = dss:GetDataStore("banDataStore")
script.Parent.BanEvent.OnServerEvent:Connect(function(player, userName, reason)
local success, errormessage = pcall(function()
local plr = game.Players:FindFirstChild(userName)
if plr then
bds:SetAsync(plr.UserID, true)
end
end)
if success then
warn(userName.."was banned!")
end
game.Players:FindFirstChild(userName):Kick(reason)
end)
1 Like
yes, i believe because it finds the first child of the player list and kicks them when the ban event is fired, it’d probably be best to go through the entire player list to find the player that you designate using a iv pairs loop perhaps
How would I set the banned value to true with the top part of the script?
local dss = game:GetService("DataStoreService")
local bds = dss:GetDataStore("banDataStore")
script.Parent.BanEvent.OnServerEvent:Connect(function(player, userName, reason)
local success, errormessage = pcall(function()
local plr = game.Players:FindFirstChild(userName)
if plr then
bds:SetAsync(plr.UserID, true)
end
end)
if success then
warn(userName.."was banned!")
end
game.Players:FindFirstChild(userName):Kick(reason)
end)
game.Players.PlayerAdded:Connect(function(PlayerName)
local banned
local success, errormessage = pcall(function()
banned = bds:SetAsync(PlayerName.UserId)
end)
if banned == true then
PlayerName:Kick("Banned")
end
end)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.