Advertisement
DaDogeDevelopment

Ban Scripts

Nov 22nd, 2022 (edited)
960
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.22 KB | None | 0 0
  1. RemoteEvent: Ban (RS)
  2. MainScript (SSS)
  3. BanFolder (MainScript)
  4. BoolValue: IsBanned (BanFolder)
  5. StringValue: PlayerName (BanFolder)
  6. StringValue: Reason (BanFolder)
  7. IntValue: Time (BanFolder)
  8. LocalScript (BanButton)
  9.  
  10.  
  11. MainScript:
  12.  
  13. local BanFolder = script.BanFolder
  14. DataStore = game:GetService("DataStoreService"):GetDataStore("TestBan")
  15.  
  16. game.Players.PlayerAdded:Connect(function(plr)
  17.     local NewBanFolder = BanFolder:Clone()
  18.     NewBanFolder.Parent = plr
  19.     plr.BanFolder.PlayerName.Value = DataStore:GetAsync(plr.UserId.."-Player")
  20.     plr.BanFolder.Time.Value = DataStore:GetAsync(plr.UserId.."-Time")
  21.     plr.BanFolder.Reason.Value = DataStore:GetAsync(plr.UserId.."-Reason")
  22.     plr.BanFolder.IsBanned.Value = DataStore:GetAsync(plr.UserId.."-IsBanned")
  23.  
  24.     if plr.BanFolder.IsBanned.Value == true then
  25.         if os.time() >= plr.BanFolder.Time.Value then
  26.             plr.BanFolder.IsBanned = false
  27.         else
  28.             local TimeBan = plr.BanFolder.Time.Value - os.time()
  29.             plr:Kick("You have been banned by "..plr.BanFolder.PlayerName.Value..". You have been banned for "..TimeBan.. " seconds. Reasoning is: "..plr.BanFolder.Reason.Value)
  30.         end
  31.     end
  32. end)
  33.  
  34. game.ReplicatedStorage.Ban.OnServerEvent:Connect(function(plr,plrToBan,Time,Reason)
  35.     local TimeNumber = tonumber(Time)
  36.     local TimeForBan = os.time() + TimeNumber
  37.     plrToBan = game.Players:FindFirstChild(plrToBan)
  38.    
  39.     plr.BanFolder.PlayerName.Value = plr.Name
  40.     plr.BanFolder.Time.Value = TimeForBan
  41.     plr.BanFolder.Reason.Value = Reason
  42.     plr.BanFolder.IsBanned.Value = true
  43.     plr:Kick("You have been banned by "..plr.BanFolder.PlayerName.Value..". You have been banned for "..TimeForBan.." seconds. Reasoning is: "..plr.BanFolder.Reason.Value)
  44. end)
  45.  
  46. game.Players.PlayerRemoving:Connect(function(plr)
  47.     DataStore:SetAsync(plr.UserId.."-Player",plr.BanFolder.PlayerName.Value)
  48.     DataStore:SetAsync(plr.UserId.."-Time",plr.BanFolder.Time.Value)
  49.     DataStore:SetAsync(plr.UserId.."-Reason",plr.BanFolder.Reason.Value)
  50.     DataStore:SetAsync(plr.UserId.."-IsBanned",plr.BanFolder.IsBanned.Value)
  51. end)
  52.  
  53.  
  54. LocalScript:
  55. script.Parent.MouseButton1Click:Connect(function()
  56.     game.ReplicatedStorage.Ban:FireServer(script.Parent.Parent.Playername.Text, script.Parent.Parent.Time.Text, script.Parent.Parent.Reason.Text)
  57. end)
  58.  
  59.  
Tags: Roblox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement