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

Why is this not working? the value doesn't go up but it prints check...

Asked by 6 years ago

I'm confused why it's still not working the problem is the value doesn't go up but the stuff gets printed... like it says check for the print"check")

01local v = game.Lighting:WaitForChild("ONE")
02local sway = math.random(1, 100) * math.random(0.05, 0.15)
03local y = math.random(1,10)
04local x = math.random(1,1)
05while wait() do
06y=math.random(1,10)
07wait(15)
08 
09print("Changing Values...")
10v.Value = v.Value + sway
11 
12if y == 5 then
13    v.Value = v.Value * 1.1 * math.random(1.7, 2.1)
14    print("Multiplied ONE")
15    elseif y == 6 then
View all 46 lines...
0
wait 6 is there twice lol... idk if thats the problem but i'll see JohnerDev 27 — 6y
0
nvm didn't work JohnerDev 27 — 6y
0
elseif y == 6 then v.Value = v.Value - v.Value + 2.50 print("ONE just crashed!!!") elseif y == 6 then v.Value = v.Value + sway print("check") JohnerDev 27 — 6y
0
i fixed that but still didn't work value didn't change JohnerDev 27 — 6y

1 answer

Log in to vote
0
Answered by
Sir_Melio 221 Moderation Voter
6 years ago

I don't think math.random accepts decimals as arguments. Use Random.new instead, like so:

1local ran = Random.new()
2 
3local sway = ran:NextNumber(0.05, 15)

You can read the wiki about the Random datatype here.

0
lol what i have now works without Random.new JohnerDev 27 — 6y
0
But thanks anyway JohnerDev 27 — 6y
Ad

Answer this question