#Leaderstats isn't working

1 messages · Page 1 of 1 (latest)

narrow latch
#

Before I start i want to say i am very new to lua code so don't get mad if this is a easy fix that i was too dumb to see. here is the code btw:

game.Players.PlayerAdded:Connect(function(player)
local Leaderstats = Instance.new("Folder")
Leaderstats.Name = "Leaderstats"
Leaderstats.Parent = player

local TimeSurvived = Instance.new("IntValue")
TimeSurvived.Name = "Time Survived"
TimeSurvived.Parent = Leaderstats
TimeSurvived.Value = 0
local humaniod = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
while true do
    wait(1)
    TimeSurvived.Value = TimeSurvived.Value + 1
    if humaniod.Health == 0 then
        if humaniod.Health == 0 then
            TimeSurvived.Value = 0
            task.wait(5)
            TimeSurvived.Value = TimeSurvived.Value + 1
        end
    end
end

end)

crude pumice
crude pumice
#

just use the player argument that you get from player added