so i tried math.random to create a script that repeatedly search a number until a specific number is chosen, for now im using a print. also this is inside a normal script, not a local
local chance = math.random(0, 5)
while true do
wait(5)
if chance == 3 then
print("les goo")
end
end
before it worked but it was nonstop printing because it was a wait(). so i added a wait(5) and now it wont work, i even set the wait to wait() again but still not working
is it because the math.random wont pick up 3 or theres something wrong about my script?
I assume that your chance variable here isn’t in a loop. Meaning essentially it won’t change at all, making your loop useless if the first time it runs it isn’t 3. Try something like this. There are better, more efficient ways to do this by the way but I’m simply basing this off your current script. Mind the mobile formatting here.
while true do -- your loop
task.wait(5) -- wait 5 seconds
local chance = math.random(1, 5) -- pick a number every 5 seconds
if chance == 3 then -- check if that number is 3
print("epic") -- print what you want
end
end
2 Likes
local chance = math.random(0, 5)
while true do
wait(5)
chance = math.random(0, 5)
if chance == 3 then
print("les goo")
end
end