# How to get a timer using labels. (Begginer Question)

**URL:** <https://forum.defold.com/t/how-to-get-a-timer-using-labels-begginer-question/36682>\
**Category:** Questions\
**Created:** [December 4, 2018, 3:56am UTC](https://forum.defold.com/t/how-to-get-a-timer-using-labels-begginer-question/36682 "2018-12-04T03:56:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidtl1900](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/d/f6c823/32.png) [@davidtl1900](https://forum.defold.com/u/davidtl1900)\
**Post date:** [December 4, 2018, 3:56am UTC](https://forum.defold.com/t/how-to-get-a-timer-using-labels-begginer-question/36682/1 "2018-12-04T03:56:15Z")

</div>

I’ve been trying to create a simple function that makes a timer which increases every second.

This is my script.

```lua
function init(self)
	self.st = 0
end

function update(self, dt)
	self.st = self.st + dt
	local time = self.st
	label.set_text("#label", "Survival Time "local time"")
	end
end

```

But every time I try to build it says I need to add a parenthesis near local. I have tried to reformat it, using self.st itself, adding parenthesis and hash marks but it still won’t even load so I can’t even figure out if there are errors in the rest of my code.

---

<div class="post-metadata">

**Author:** ![COCO](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/coco/32/38692_2.png) [@COCO](https://forum.defold.com/u/COCO)\
**Post date:** [December 4, 2018, 4:46am UTC](https://forum.defold.com/t/how-to-get-a-timer-using-labels-begginer-question/36682/2 "2018-12-04T04:46:04Z")

</div>

```
function init(self)
	self.st = 0
end

function update(self, dt)
	self.st = self.st + dt
	local time = self.st
	label.set_text("#label", "Survival Time "..time)
end

```

---

<div class="post-metadata">

**Author:** ![sicher](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sicher/32/8_2.png) [@sicher](https://forum.defold.com/u/sicher)\
**Post date:** [December 4, 2018, 8:02am UTC](https://forum.defold.com/t/how-to-get-a-timer-using-labels-begginer-question/36682/3 "2018-12-04T08:02:22Z")

</div>

Explanation:

1. The word `local` should only be used when defining a new local variable (one that is visible in the current scope, basically until the next `end`), not when using it later on.
2. Strings are concatenated with the `..` operator.

---

<div class="post-metadata">

**Author:** ![davidtl1900](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/d/f6c823/32.png) [@davidtl1900](https://forum.defold.com/u/davidtl1900)\
**Post date:** [December 5, 2018, 2:06am UTC](https://forum.defold.com/t/how-to-get-a-timer-using-labels-begginer-question/36682/4 "2018-12-05T02:06:22Z")

</div>

Thanks
