What is wrong with my timer?

It won’t add the stats.

Server Sided:

finishedRemote.OnServerEvent:Connect(function(player, Time)
	
	local BestTimeStat = player.leaderstats.BestTime
	
	Time = tonumber(Time)
	
	if BestTimeStat.Value > Time and BestTimeStat.Value ~= 0 and game.Workspace.Level1.Stop.Touched == true then
		BestTimeStat.Value = Time
		print("Set the stats")
	elseif BestTimeStat.Value < Time and BestTimeStat.Value ~= 0 and game.Workspace.Level1.Stop.Touched == true then
		print("To slow")
	elseif BestTimeStat.Value == 0 and game.Workspace.Level1.Stop.Touched == true then
		
		BestTimeStat.Value = Time
	end
	
end)

Client



local player = game:GetService("Players").LocalPlayer

local TimeText = script.Parent.TimeText
local Playing = script.Parent.Parent.Parent:WaitForChild("Playing")
local Time = 0

local finishedRemote = game:GetService("ReplicatedStorage"):WaitForChild("finishedTime")

local RationalDigits = 2

local Accuracy = 10^RationalDigits
local function roundTimer()
	local Div1 = math.abs(tick() - current_time)
	local CalculatedIncrement = math.round(Div1*Accuracy)/Accuracy
	local Addons={}
	for t=1,RationalDigits do
		local i = t-1
		local integer,predecimal = math.modf(CalculatedIncrement*(10^i))
		local decimal = predecimal/(10^i)
		if decimal == 0 then
			Addons[t] = "0"
		end

	end
	NewText = tostring(CalculatedIncrement)
	for i,v in pairs(Addons) do
		NewText = NewText..v
	end
	TimeText.Text = NewText

end





TimerOn = false

while wait() do
	if Playing.Value == true then

		current_time = tick()
		TimerOn = true
		break
	else

		TimerOn = false

	end
end
while TimerOn == true do
	if Playing.Value == true then
		TimeText.TextColor3 = Color3.new(255, 255, 255)
		TimeText.Visible = true
		TimeText.Text = Time.."s"
		wait(0.1)
		roundTimer()
		Time = NewText


	elseif Playing.Value == false then
		local Time = (tick() - current_time)
		finishedRemote:FireServer(Time)

		TimeText.TextColor3 = Color3.new(0, 255, 0)
		TimerOn = false
		TimeText.Visible = false
		Time = 0
		break
	end
end

You can’t do that. You can use GetTouchingParts to check if two parts are touching.

Interesting, it seemed to been working before I made the tick() so I would check for humanoid rootpart?

Yup, the reason why it doesn’t work is because BasePart.Touched is an event (or RBXScriptSignal) and not a property.

Is there a :IsA(“Character”) or something to check if it is a player

You can check if there is a Humanoid in the character.

Should something like this work?

finishedRemote.OnServerEvent:Connect(function(player, Time)
	
	local BestTimeStat = player.leaderstats.BestTime
	
	Time = tonumber(Time)
	
	local humanoidTouched = false
	
	local touchingParts = game.Workspace.Level1.Stop:GetTouchingParts()
	
	
	for _, v in pairs(touchingParts) do -- loops through all the touching parts
		if v.Parent:FindFirstChild("HumanoidRootPart") then
			humanoidTouched = true
		end
	end
	
	
	if BestTimeStat.Value > Time and BestTimeStat.Value ~= 0 and humanoidTouched == true then
		BestTimeStat.Value = Time
		print("Set the stats")
	elseif BestTimeStat.Value < Time and BestTimeStat.Value ~= 0 and humanoidTouched == true then
		print("To slow")
	elseif BestTimeStat.Value == 0 and humanoidTouched == true then
		
		BestTimeStat.Value = Time
	end
	
end)

no no, you would use Players:GetPlayerFromCharacter(character) to see if the character is a player’s character or not. If it is, it would return the player or else it would return nil

Solved, thanks to @Vaschex and @iamtryingtofindname for helping :smiley: