Skip to content

Instantly share code, notes, and snippets.

@ohusq
Created July 18, 2024 18:20
Show Gist options
  • Save ohusq/d74a916b8dba03cda26a9ebd8ef6d3f9 to your computer and use it in GitHub Desktop.
Save ohusq/d74a916b8dba03cda26a9ebd8ef6d3f9 to your computer and use it in GitHub Desktop.
players.PlayerAdded:Connect(function(player)
local data = db:getDataForInstance(player.UserId)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local kills = Instance.new("IntValue", leaderstats)
kills.Name = "Kills"
kills.Value = data.Kills
local deaths = Instance.new("IntValue", leaderstats)
deaths.Name = "Deaths"
deaths.Value = data.Deaths
player.CharacterRemoving:Connect(function(character: Model)
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
if humanoid:GetState() == Enum.HumanoidStateType.Dead then
print(`{player.Name} has died`)
end
end
end)
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment