So, I made this ban GUI, and when I ban someone the ban doesn't save! Here are the scripts involved with this.
Local script in GUI.
script.Parent.MouseButton1Click:Connect(function()
local Username = script.Parent.Parent.Username.TextBox.Text
local Reason = script.Parent.Parent.Reason.TextBox.Text
local Evidence = script.Parent.Parent.Evidence.TextBox.Text
print("Button was pressed!")
if game.Players:FindFirstChild(Username) then
print("Succesfully got a player!")
game.ReplicatedStorage.ModEvents.BanPlayer:FireServer(Username, Reason)
else
print("Player does not exist!")
end
end)
Server script that gets the remote event.
game.ReplicatedStorage.ModEvents.BanPlayer.OnServerEvent:Connect(function(player, Username, Reason)
game.Players:FindFirstChild(Username):Kick("\nYou have been banned for:\n"..Reason.."\n By: "..player.Name.. " | "..player.UserId)
game.Players:FindFirstChild(Username).modstats.Banned.Value = true
game.Players.PlayerAdded:Connect(function(player)
if player.modstats.Banned.Value == true then
player:Kick("\nYou are banned for:\n"..Reason.."\n By: "..player.Name.. " | "..player.UserId)
end
end)
end)
Datastore script.
local Players = game:GetService("Players");
local DataStoreService = game:GetService("DataStoreService");
local Datastore = DataStoreService:GetDataStore("BucksDataStore");
Players.PlayerAdded:Connect(function(player)
local modstats = Instance.new("Folder", player)
modstats.Name = "modstats"
local Banned = Instance.new("BoolValue", modstats)
Banned.Name = "Banned"
Banned.Value = false
local data = nil;
local s, e = pcall(function()
data = Datastore:GetAsync(player.UserId.."-cash")
end)
if(s) then
print("Data successfully loaded.")
data = data or false
Banned.Value = data
else
warn("There was a problem loading data:", e);
end
end);
Players.PlayerRemoving:Connect(function(player)
local modstats = player.modstats
local Banned = modstats.Banned
local s, e = pcall(function()
Datastore:SetAsync(player.UserId.."-cash", Banned.Value)
end);
if(s) then
print("Data successfully saved.");
else
warn("There was a problem saving data:", e);
end
end)
If anyone could help, that would be greatly appreciated.

1 comment
I dont really know how to script but there is a solution you can use I have this script ypu can use but you need to gtoto roblox studio