Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

When value has a multiple of 10 script?

Asked by
jakeovi -1
4 years ago

I've already got the code, how do I make multiples as a number?

workspace.Rounds:GetPropertyChangedSignal("Value"):Connect(function()
    if workspace.Rounds.Value == 10 20 30 40 50  then

    end
end)
0
Are you asking how to see if the number (workspace.Rounds.Value) is a number that is a multiple of 10? DeveloperColton 229 — 4y
0
its when the value is a multiple of 10 jakeovi -1 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

You can use the % operator in lua which gets the remainder after divison. So in your usecase, any number that is a multiple of 10 will pass.

workspace.Rounds:GetPropertyChangedSignal("Value"):Connect(function()
    if workspace.Rounds.Value % 10 == 0 then
        -- Rest of code.
    end
end)
0
OK! I will test it, stay safe from covid jakeovi -1 — 4y
0
Thank you :) Stay safe as well, please accept the answer if it ends up working out for you! :D DeveloperColton 229 — 4y
0
It works, Thanks. jakeovi -1 — 4y
0
also how do i accept the answer? i dont see a button jakeovi -1 — 4y
View all comments (4 more)
0
It is down at the bottom under this text box. http://prntscr.com/s4ahbf DeveloperColton 229 — 4y
0
all i just see is report jakeovi -1 — 4y
0
I'm not too sure- it might be because your account is new. Maybe wait a little and try later? Good luck :) DeveloperColton 229 — 4y
Ad
Log in to vote
0
Answered by
Sulu710 142
4 years ago

In order to see if a number is a multiple of ten, you'd want to divide that number by ten to see if it comes out as a whole number. Change your script to this:

workspace.Rounds:GetPropertyChangedSignal("Value"):Connect(function()
    num = workspace.Rounds.Value/10
    if num == math.floor(num)

    end
end)

math.floor rounds the number down. So if a number is the same as itself floored, then it is a whole number because it never had to be rounded. I hope this helps!

Answer this question