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

Why isn't this script not working? Is it to do with I should stored it as a variable?

I have a generator which I named the humanoid "Generator" And I want this script to make this gui visible when the generator dies.

local z = script.Parent

while true do
	wait(5)
	if z.Generator.Health == 0 then
		game.StarterGui.EndScreen.Frame.Visible = true
		
		
	end
	if z == nil then
		game.StarterGui.EndScreen.Frame.Visible = true
	end
end 

1 answer

✓ Accepted answer

It's because you haven't fully referenced generator so try my updated script below

local z = script.Parent

while true do
    wait(5)
Generator:WaitForChild("Humanoid").Died then
        game.StarterGui.EndScreen.Frame.Visible = true

    end
    if z == nil then
        game.StarterGui.EndScreen.Frame.Visible = true
    end
end 

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