Best time script not working

Hey, so trying to make a script with a best time and time alive thing I got the time alive part working, and now every second the leaderboard value with Timealive works. although, the BestTime part on the otherhand doesn’t work. Each time I reset, it doesn’t change at all and stays at 0 no longer how long I have been playing / how large my Timealive is.

Script (in starterplayerscripts):

local humanoid = script.Parent:WaitForChild("Humanoid")

local player = game.Players:GetPlayerFromCharacter(script.Parent)
local leaderstats = player:WaitForChild("leaderstats")
local aliveTime = leaderstats:WaitForChild("Timealive")
local bestTime = leaderstats:WaitForChild("BestTime")

humanoid.Died:Connect(function()
	if aliveTime.Value >= bestTime.Value then
		bestTime.Value = aliveTime.Value
	end

	aliveTime.Value = 0
end)

while wait(1) do
	if humanoid.Health == 0 then
		break
	end

	aliveTime.Value += 1
end
1 Like

Hi,

The script you provided works, though you should put it in StarterCharacterScripts (not StarterPlayerScripts).

devforum

1 Like

If you actually meant to say startercharacterscripts, there’s most likely another script interferring with your BestTime value.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.