no errors and i don’t know why its not changing to it
Your for loop has the increment set to 1 however the numbers are going down (30 → 0)
Change inc to -1.
... = Module.Counter(30,0,-1,"Round Time Left: ")
Edit, I have just noticed you are doing ‘-inc’ in the for loop so this is not the issue.
the text still not showing on the text Label what to do?
Your module is currently just iterating from 30 to 0 and then returning nil. You need to add code in the for loop that sets the text to the value of inc
Could you give us a better explanation of what exactly is happening in your code? Just putting down code doesn’t help much, especially because we are suppose to help you through this, not just give code to you. And just putting down your code doesn’t really give us any context on your problem.
You aren’t returning anything from your module function though, so if you are trying to set the text of a textlabel
to something your function picks up, you would need to return something.
Yea what Naco88 said is true, add another parameter to your module.Counter which is the textLabel and in your for loop in the module.Counter set the text there
can you show me example please
Firstly, change
TimerClone.Frame.Time.Text = module.Counter(30,0,1,"Round Time Left: ")
to
module:Counter(30,0,1,"Round Time Left: ", TimerClone.Frame.Time)
Now change your module script to the following:
local module = {}
function module:Counter(num1,num2,inc,prefix,textLabel)
for i = num1,num2,-inc do
textLabel.Text = prefix..tostring(i)
wait(inc)
end
end
return module
Naco88 is right, it is because the function first finishes itself until it returns a value, whilst the function is running itself, the text won’t be changed.
Naco88’s solution is what it should be unless it gives an error of coarse, I haven’t tested it myself
Naco88 this what it errors me : “attempt to concatenate nil with string”
change
prefix..tostring(inc)
to
prefix..tostring(i)
I guess that should make it work
Make sure you changed both 2 pieces of script
still not working and it still make the error : “attempt to concatenate nil with string”
Oh yeah probably because you’re using module.Func = … which I believe passes self as a parameter.
I updated both code snippets. Try them again.
(post withdrawn by author, will be automatically deleted in 1 hour unless flagged)
that’s what I just said eeeeee, the i
it still printing the error “attempt to concatenate nil with string”
now its printing the error "attempt to perform arithmetic (unm) on nil "
print your variables to test it out at the top of your module:Counter
print(num1,num2,inc,prefix,textLabel)
you can print separate and space also if you want
have you added both pieces of script? like replaced both the line where the function is called and the lines of the function itself? wrong arguments can maybe cause this
You don’t have to wait(30)
in event.OnClientEvent:Connect() because inside module.Counter, it already waits for each second.