Death screen isn't working

My death screen isn’t working - I’d like someone to help me with it.

Screenshot of Fully Opened Gui:
image

ScoreScript text:

local score = script.Parent
local gui = script.Parent.Parent.Parent

while true do
	if gui.Visible == true then
		score.Text = "Score: "..math.random(1, 100)
	end
	wait(5)
end

RespawnScript text:

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Parent.Enabled = false
	--w.i.p--
end)

The issue is that you are using .Visible on script.Parent.Parent.Parent, which is a ScreenGui, which does not have that property, but has .Enabled instead.

local score = script.Parent
local gui = script.Parent.Parent.Parent

while true do
	if gui.Enabled == true then
		score.Text = "Score: "..math.random(1, 100)
	end
	wait(5)
end

like that?

Using a while true do loop just to check every time, each second, or any selected wait duration is a bad practice. You should use the GetPropertyChangedSignal event instead.

local score = script.Praent
local gui = script.Parent.Parent

gui:GetPropertyChangedSignal("Enabled"):Connect(function()
  if gui.Enabled then
     score.Text = "Score: " .. math.random(1, 100);
  end
end)

I’d also like to point out like PhoenixRessusection; you are trying to use .Visible on script.Parent.Parent.Parent which is a ScreenGUI instance. ScreenGUIs do not have that property, rather, they have the Enabled property.

2 Likes