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

Script doesn't run function even though it's called?

Asked by 9 years ago
function newSkin()
    if(math.random(1) > 0.5) then
        print("bigger")
    else
        print("smaller")
    end
end

if(player:WaitForDataReady()) then
    wait(script.Parent.Visible == true)
    x = 0
    while(x < 500000) do
        script.Parent.MouseButton1Click:connect(function()
            newSkin()
        end)
        x = x + 1
        wait(0.03)
    end
    player:Destroy()
end


Why doesn't it even load "newSkin()"? You can see the game here. I'm baffled

1 answer

Log in to vote
0
Answered by 9 years ago

First off, you don't need to connect the function to the event half a million times. Second, try changing line 2 to this: if (math.random(1,2)>1) then Finally, try taking out the WaitForDataReady(). The final script should look like this:

function newSkin()
    if math.random(1,2)>1 then
        print("bigger")
    else
        print("smaller")
    end
end
script.Parent.MouseButton1Click:connect(newSkin)

That should fix the newSkin() issue. Hope this helped!

Ad

Answer this question