Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RemoteEvent: Ban (RS)
- MainScript (SSS)
- BanFolder (MainScript)
- BoolValue: IsBanned (BanFolder)
- StringValue: PlayerName (BanFolder)
- StringValue: Reason (BanFolder)
- IntValue: Time (BanFolder)
- LocalScript (BanButton)
- MainScript:
- local BanFolder = script.BanFolder
- DataStore = game:GetService("DataStoreService"):GetDataStore("TestBan")
- game.Players.PlayerAdded:Connect(function(plr)
- local NewBanFolder = BanFolder:Clone()
- NewBanFolder.Parent = plr
- plr.BanFolder.PlayerName.Value = DataStore:GetAsync(plr.UserId.."-Player")
- plr.BanFolder.Time.Value = DataStore:GetAsync(plr.UserId.."-Time")
- plr.BanFolder.Reason.Value = DataStore:GetAsync(plr.UserId.."-Reason")
- plr.BanFolder.IsBanned.Value = DataStore:GetAsync(plr.UserId.."-IsBanned")
- if plr.BanFolder.IsBanned.Value == true then
- if os.time() >= plr.BanFolder.Time.Value then
- plr.BanFolder.IsBanned = false
- else
- local TimeBan = plr.BanFolder.Time.Value - os.time()
- plr:Kick("You have been banned by "..plr.BanFolder.PlayerName.Value..". You have been banned for "..TimeBan.. " seconds. Reasoning is: "..plr.BanFolder.Reason.Value)
- end
- end
- end)
- game.ReplicatedStorage.Ban.OnServerEvent:Connect(function(plr,plrToBan,Time,Reason)
- local TimeNumber = tonumber(Time)
- local TimeForBan = os.time() + TimeNumber
- plrToBan = game.Players:FindFirstChild(plrToBan)
- plr.BanFolder.PlayerName.Value = plr.Name
- plr.BanFolder.Time.Value = TimeForBan
- plr.BanFolder.Reason.Value = Reason
- plr.BanFolder.IsBanned.Value = true
- plr:Kick("You have been banned by "..plr.BanFolder.PlayerName.Value..". You have been banned for "..TimeForBan.." seconds. Reasoning is: "..plr.BanFolder.Reason.Value)
- end)
- game.Players.PlayerRemoving:Connect(function(plr)
- DataStore:SetAsync(plr.UserId.."-Player",plr.BanFolder.PlayerName.Value)
- DataStore:SetAsync(plr.UserId.."-Time",plr.BanFolder.Time.Value)
- DataStore:SetAsync(plr.UserId.."-Reason",plr.BanFolder.Reason.Value)
- DataStore:SetAsync(plr.UserId.."-IsBanned",plr.BanFolder.IsBanned.Value)
- end)
- LocalScript:
- script.Parent.MouseButton1Click:Connect(function()
- game.ReplicatedStorage.Ban:FireServer(script.Parent.Parent.Playername.Text, script.Parent.Parent.Time.Text, script.Parent.Parent.Reason.Text)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement