Hello, I would like to know if someone can help me to save a bool value in the player and that this is saved in the server please
I need to create a boolValue that is Parent to the player and that this value is saved in the servers, I need to be able to manipulate this bool value in the future, sorry for the inconvenience
example:
boolValue false → when the player joins the server boolValue true → the value true will be saved in the player if it leaves and enters the server it will always be true
I have read about saving the data and it has been very complicated for me… I really can’t understand how to do this
I need it to happen after this, I want to make that whoever has the value true cannot enter the server again and whoever has the value false can enter
if Player.TeamColor == BrickColor.new("Slime green") then
for i,Player2 in pairs(Players:GetPlayers()) do
if message == '.ban ' .. Player2.Name then
print("The player name is ..." .. Player2.Name)
print("You have been banned by the administrator")
-- How could i ban the player here?
-- code to ban the player here:
end
end
end
I need it to happen after this, I want to make that whoever has the value true cannot enter the server again and whoever has the value false can enter
if Player.TeamColor == BrickColor.new("Slime green") then
for i,Player2 in pairs(Players:GetPlayers()) do
if message == '.ban ' .. Player2.Name then
print("The player name is ..." .. Player2.Name)
print("You have been banned by the administrator")
-- How could i ban the player here?
-- code to ban the player here:
end
end
end
local banList = {}
--Use this VV to add players to the ban table.
table.insert(banList,tobanvariable.UserId) --Replace "tobanvariable" with your target variable.
function Check(plr)
local inst = plr
for i,v in pairs(banList) do
if v.UserId == inst.UserId then
inst:Kick("You have been banned from this server by an administrator..")
end
end
end
game:GetService("Players").PlayerAdded:Connect(Check)
---- ADMINS
local banList = {}
--Use this VV to add players to the ban table.
--Replace "tobanvariable" with your target variable.
function Check(plr)
local inst = plr
for i,v in pairs(banList) do
if v.UserId == inst.UserId then
inst:Kick("You have been banned from this server by an administrator..")
end
end
end
game:GetService("Players").PlayerAdded:Connect(Check)
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(message)
if Player.TeamColor == BrickColor.new("Slime green") then
for i,Player2 in pairs(Players:GetPlayers()) do
if message == '.kick ' .. Player2.Name then
print("The player name is ..." .. Player2.Name)
Player2:Kick("You have been kicked by the owner.")
end
end
end
if Player.TeamColor == BrickColor.new("Slime green") then
for i,Player2 in pairs(Players:GetPlayers()) do
if message == '.warn ' .. Player2.Name then
print("The player name is ..." .. Player2.Name)
print("The administrator has given you a warning")
end
end
end
if Player.TeamColor == BrickColor.new("Slime green") then
for i,Player2 in pairs(Players:GetPlayers()) do
if message == '.ban ' .. Player2.Name then
print("The player name is ..." .. Player2.Name)
print("You have been banned by the administrator")
-- How could i ban the player here?
-- code to ban the player here:
table.insert(banList,Player2.UserId)
end
end
end
end)
end)
--
---- ADMINS
local banList = {}
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(message)
if Player.TeamColor == BrickColor.new("Slime green") then
for i,Player2 in pairs(Players:GetPlayers()) do
if message == '.kick ' .. Player2.Name then
print("The player name is ..." .. Player2.Name)
Player2:Kick("You have been kicked by the owner.")
end
end
end
if Player.TeamColor == BrickColor.new("Slime green") then
for i,Player2 in pairs(Players:GetPlayers()) do
if message == '.warn ' .. Player2.Name then
print("The player name is ..." .. Player2.Name)
print("The administrator has given you a warning")
end
end
end
if Player.TeamColor == BrickColor.new("Slime green") then
for i,Player2 in pairs(Players:GetPlayers()) do
if message == '.ban ' .. Player2.Name then
print("The player name is ..." .. Player2.Name)
print("You have been banned by the administrator")
-- How could i ban the player here?
-- code to ban the player here:
table.insert(banList,Player2.UserId)
end
end
end
end)
end)
function Check(plr)
local inst = plr
for i,v in pairs(banList) do
if v.UserId == inst.UserId then
inst:Kick("You have been banned from this server by an administrator..")
end
end
end
game:GetService("Players").PlayerAdded:Connect(Check)
--
Hm, the way you have commands setup it’s kinda hard making it check for a table as you have no arguments variable. Could you try using a different command system?
Alright, you will have to add your rank checking system yourself as I’m not sure how you want it to be done, but here is a plain command system (with kick, ban, & unban) This does NOT check if they have perms, you have to add it yourself
---- ADMINS
local banList = {}
local Players = game:GetService("Players")
local function ChatCMD(player, msg)
if msg:sub(1,5):lower() == ".ban " then
local target = Players:FindFirstChild(msg:sub(6))
if target:IsA("Player") then
table.insert(banList,target.UserId)
else
print("Not a valid player!")
end
elseif msg:sub(1,6):lower() == ".kick " then
local target = Players:FindFirstChild(msg:sub(6))
if target:IsA("Player") then
target:Kick("You have been kicked.")
else
print("Not a valid player!")
end
elseif msg:sub(1,7):lower() == ".unban " then
pcall(function()
local target = table.find(banList,msg:sub(8)) --You will have to unban via their UserID not username.
table.remove(banList,target)
end)
end
end
function Check(plr)
local inst = plr
for i,v in pairs(banList) do
if v.UserId == inst.UserId then
inst:Kick("You have been banned from this server by an administrator..")
end
end
end
game:GetService("Players").PlayerAdded:Connect(Check)
local function onPlayerAdded(player)
player.Chatted:Connect(function (message) ChatCMD(player, message) end)
end
--