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

Why won't this script work? [solved]

Asked by 9 years ago
if script.Parent.Visible == true then
    script.Parent.Text = "Power: 99%"
    wait(10)
    script.Parent.Text = "Power: 85%"
    wait(20)
    script.Parent.Text = "Power: 67%"
    wait(3)
    script.Parent.Text = "Power: 64%"
    wait(19)
    script.Parent.Text = "Power: 48%"
    wait(27)
    script.Parent.Text = "Power: 20%"
    wait(19)
    script.Parent.Text = "Power: 1%"
    wait(1)
    script.Parent.Text = "Power: 0%"
    wait(3)
    script.Parent.Parent.flash.click.Disabled = true
    game.Lighting.Ambient = Color3.new(31/255,31/255,31/255)
    script.Parent.Parent.flashclose.Visible = false
    script.Parent.Text = "Out of power."
end

It's not doing anything. It's not disabled either. When the parent is visible, nothing happens.

1 answer

Log in to vote
1
Answered by 9 years ago

The code only checks if the parent is visible when the game starts. You need to add a while loop.

while wait(1) do --This checks every second so that the game doesn't lag or crash. You can make this faster, but be careful.
    if script.Parent.Visible == true then
        script.Parent.Text = "Power: 99%"
        wait(10)
        script.Parent.Text = "Power: 85%"
        wait(20)
        script.Parent.Text = "Power: 67%"
        wait(3)
        script.Parent.Text = "Power: 64%"   
        wait(19)
        script.Parent.Text = "Power: 48%"
        wait(27)
        script.Parent.Text = "Power: 20%"
        wait(19)
        script.Parent.Text = "Power: 1%"
        wait(1)
        script.Parent.Text = "Power: 0%"
        wait(3)
        script.Parent.Parent.flash.click.Disabled = true
        game.Lighting.Ambient = Color3.new(31/255,31/255,31/255)
        script.Parent.Parent.flashclose.Visible = false
        script.Parent.Text = "Out of power."
    end
end
Ad

Answer this question