I was making a game that when the Player dies, then the Player will get banned but isn't working (The part of Saving the Bool Value that checks if the player was banned already been banned). How i can fix that? No errors in output.
Code:
local DataStoreService = game:GetService("DataStoreService")
local BANS = DataStoreService:GetDataStore("BANNED")
game.Players.PlayerAdded:Connect(function(Player)
local Char = Player.CharacterAdded:Wait() or Player.Character
local Hum = Char:WaitForChild("Humanoid") or Char.Humanoid
local banornot = Instance.new("Folder")
banornot.Name = "Banned"
banornot.Parent = Player
local banned = Instance.new("BoolValue", banornot)
banned.Name = "Banido"
banned.Value = false
local PlayerId = Player.UserId
local BANIDO = BANS:GetAsync(PlayerId)
Hum.Died:Connect(function()
if not BANIDO then
BANS:SetAsync(PlayerId, banned.Value)
Player:Kick("You can't join the game.")
end
end)
end)
game.Players.PlayerAdded:Connect(function(Player)
local PlayerId = Player.UserId
local banidovalue = Player:WaitForChild("Banned"):WaitForChild("Banido").Value
local BANIDO = BANS:GetAsync(PlayerId, banidovalue)
if BANIDO then
banidovalue = true
if banidovalue == true then
Player:Kick("You can't join the game. Sorry you know the rules.")
else print("erro")
end
end
end)