So I started making a racing game, and I added a invisible block at the beginning of the race. This block will start a stopwatch at the top of the players screen. This is the code:
local stopwatch = 0
local Debounce = false
function stopWatchstart()
while true do
stopwatch = stopwatch + 1
wait(1)
script.Parent.Text = (stopwatch.."")
end
end
game.Workspace.StartStopwatch.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if Debounce == false then
Debounce = true
stopWatchstart()
wait(5)
Debounce = false
end
end
end)
The thing is I have the part set to cancollide false (so the player can go through). But then it doesn't start the stopwatch. How do I fix this?

2 comments
Where do I have to put this code?
repace it with line 15-22