Detect amount of time player has been in certain area

I was thinking about detecting how long the player was in a certain area. I already have the area but I don’t have any idea about how would you detect the time the player has been in that area. Maybe I’m supposed to use


but I don’t know how to make it work properly.

os.clock() is just tick() but it ignores time zones. What I’d do is

local playerInZone = false --Set to true when player goes into zone
local timeInZone = 0

while playerInZone do
  timeInZone += 1 --Set this to 0 when playerInZone becomes false
1 Like