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

Loops/functions aren't starting in my script and it won't even make it to then end, any fixes?

Asked by
lukedm 0
4 years ago

I have a script which is supposed to turn on and off particles depending on if it's clicked or with a random number generator, I only got the "can break" print to show, can someone help me? An image of the explorer is in the gyazo link. https://gyazo.com/3039b5bdd28980d0555e4d82af89f426

local clickDetector = script.Parent.ClickDetector
local particle1 = script.Parent.Particle1.ParticleEmitter 
local particle2 = script.Parent.Particle2.ParticleEmitter
local particle3 = script.Parent.Particle3.ParticleEmitter

while true do
    print("can break")
    wait(43)
    local Break = math.random(1,10)
    if Break == 3 then
        particle1.Enabled = true
        particle2.Enabled = true
        particle3.Enabled = true
        print("break")
end
end

function Particlefix()
    particle1.Enabled = false
    particle2.Enabled = false
    particle3.Enabled = false
    print("fix")
end

clickDetector.MouseClick:connect(Particlefix)
print("it all loads")
0
Are you waiting 43 seconds first? TornadoCookie 20 — 4y
0
Only puts can break, the fix also doesn't seem to work and it doesn't print "it all loads" as well. lukedm 0 — 4y
0
You're using math.random. You may have to do a couple of tries for it to show its working, unless I'm wrong? nekosiwifi 398 — 4y
0
The breaking did take a century to work (bad RNG) but it eventually did, the fix doesn't work still. lukedm 0 — 4y
View all comments (2 more)
0
Maybe enclose the while true do loop in a separate thread/coroutine/spawn? radiant_Light203 1166 — 4y
0
What do you mean by that? I don't know how to enclose it in a separate thread/coroutine/spawn lukedm 0 — 4y

Answer this question