Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why won't this script work? [solved]

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

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.