Reputation: 35
I was programming a Roblox game, and I need a timer that loops, and it must add to the money IntValue. I play tested the code, but it did not loop or add to the money value. How would I solve this problem? There aren't any errors occurring. Here's the code for the timer script. It is in a local script.
local minutes = 0
local seconds = 15
local player = game.Players.LocalPlayer
local leaderstats = player:FindFirstChild("leaderstats")
local money = leaderstats:FindFirstChild("Effect Coins")
while true do
for i = 1, 15 do
wait(1)
if seconds == 0 then
minutes = minutes - 1
secconds = 59
else
seconds = seconds - 1
end
if seconds < 10 then
script.Parent.Text = tostring(minutes)..":0"..tostring(seconds)
else
script.Parent.Text = tostring(minutes)..":"..tostring(seconds)
end
end
money += 1
minutes = 0
seconds = 15
end
I tried changing the value of the time lengths, but it doesn't seem to work.
Upvotes: 0
Views: 40
Reputation: 67
From the snippet you have provided, it seems like your code does not even run properly since there are errors like:
Typos in variable:
secconds = 59
Lua does not have operator +=. Instead use:
seconds = seconds + 1
There might be another problem. When you search for money.
leaderstats:FindFirstChild("Effect
It returns reference to object. When you want to change the object you have to access its property or method.
I have never programmed anything in roblox, but i have found in documentation reference to text label. It contains property named "ContentText", what means you can change money by doing this: money.ContentText = "money value"
Upvotes: 0