Hey, again! I’ve got a problem and noticed nothing working with the scripts, there was no error in the console however there is an underline circle on the:
if success then
I have no other idea to fix this script, I’ve tried debugging it however nothing happens.
local DataStoreService = game:GetService("DataStoreService")
local banDataStore = DataStoreService:GetDataStore("banDataStore")
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local userID = Player.UserId
local success, errormessage = pcall(function()
banDataStore:SetAsync(userID, true)
if Character:FindFirstChild("Humanoid").Health == "0" then
if success then
print("someone got banned")
Player:Kick("you died, and got banned. well rip")
end
end
end)
end)
end)
The Character:FindFirstChild("Humanoid").Health will probably never equal zero, this is because the player’s health can’t go down to zero as soon as they spawn. Use Humanoid.Died instead.
local DataStoreService = game:GetService("DataStoreService")
local banDataStore = DataStoreService:GetDataStore("banDataStore")
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local userID = Player.UserId
local success, errormessage = pcall(function()
banDataStore:SetAsync(userID, true)
if Character:FindFirstChild("Humanoid").Health == 0 then
if success then
print("someone got banned")
Player:Kick("you died, and got banned. well rip")
end
end
end)
end)
end)
local DataStoreService = game:GetService("DataStoreService")
local banDataStore = DataStoreService:GetDataStore("banDataStore")
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local userID = Player.UserId
local success, errormessage = pcall(function()
banDataStore:SetAsync(userID, true)
end)
if success then
if Character:FindFirstChild("Humanoid").Health == 0 then -- make sure it 0 not "0" as "0" is a string and 0 is a number
print("someone got banned")
Player:Kick("you died, and got banned. well rip")
end
end
end)
end)