im trying to make a timer gui that starts when a player touches a specific part
local part = script.Parent
part.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
local humanoidrootpart = hit.Parent:FindFirstChild("HumanoidRootPart")
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if humanoid then
humanoidrootpart.CFrame = CFrame.new(-281.113, 87.246, -388.14)
game.ReplicatedStorage.RemoteEvent:FireClient(player)
end
end)
local localplayer = game.Players.LocalPlayer
local gui = localplayer.PlayerGui:FindFirstChild("Timer"):FindFirstChild("TextLabel")
local run = game:GetService("RunService")
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
local starttime = os.clock()
local Timer = run.Heartbeat:Connect(function()
local Elapsed = os.clock()
local Minutes = math.floor(Elapsed / 60)
local Seconds = math.floor(Elapsed % 60)
local Milliseconds = (Elapsed % 1) * 100
gui.Text = string.format("%.2d:%.2d.%.2d", Minutes, Seconds, Milliseconds)
end)
end)
but whenever the timer starts the timer doesnt start from 00:00.00