local Players = game:GetService("Players") local starts = {} local function owner(hit) local character = hit:FindFirstAncestorOfClass("Model") return character and Players:GetPlayerFromCharacter(character) end local function bind(player) player.CharacterAdded:Connect(function() starts[player] = nil end) end Players.PlayerAdded:Connect(bind) Players.PlayerRemoving:Connect(function(player) starts[player] = nil end) workspace:WaitForChild("RaceStart").Touched:Connect(function(hit) local player = owner(hit) if player and not starts[player] then starts[player] = workspace:GetServerTimeNow() end end) workspace:WaitForChild("RaceFinish").Touched:Connect(function(hit) local player = owner(hit) local began = player and starts[player] if not began then return end starts[player] = nil local duration = workspace:GetServerTimeNow() - began player:SetAttribute("LastRaceSeconds", duration) local best = player:GetAttribute("BestRaceSeconds") if not best or duration < best then player:SetAttribute("BestRaceSeconds", duration) end end)