Frame not showing

local script:

--gui properties
local screeengui = script.Parent
local frame = screeengui:WaitForChild("Frame")
local textlabel = screeengui:WaitForChild("TextLabel")
textlabel.Visible = false

--tween properties
local tween = game:GetService("TweenService")
local tsinfo = TweenInfo.new(4)
local ts = tween:Create(frame,tsinfo,{Transparency = 1})

--random properties lol
local plr = game.Players.LocalPlayer

local char = plr.Character or plr.CharacterAdded:Wait()
--functions
	char:WaitForChild("Humanoid").Died:Connect(function()
	plr:WaitForChild("Deaths").Changed:Connect(function(value)
		
		--main scrip
		textlabel.Visible = true
		if value == 1 then
			frame.Visible = true
			wait(0.0001)
			textlabel.Text = "Two more lives left."
			wait(2)
			textlabel.Visible = false
			textlabel.Text = ""
			wait(1) 
			ts:Play()
			wait(4)
			frame.Visible = false
			end
		if value == 2 then
			frame.Visible = true
			wait(0.5)
			textlabel.Text = "One more life left"
			wait(2)
			textlabel.Visible = false
			textlabel.Text = ""
			wait(1) 
			ts:Play()
			wait(4)
				frame.Visible = false
				end
	 if value == 3 then
			frame.Visible = true
			wait(0.5)
			textlabel.Text = ":)"
		
		
			
		wait(2)
end
		
	end)

	end)
1 Like

Is there a reason to misspelling “ScreenGui”?

You tween the Transparency to 1, which means it will be invisible.

Also, I’d recommend making this a function:

This would make your code something like this:

local function displayLivesLeft(text)
	frame.Visible = true
	wait(0.0001)
	textlabel.Text = text
	wait(2)
	textlabel.Visible = false
	textlabel.Text = ""
	wait(1) 
	ts:Play()
	wait(4)
	frame.Visible = false
end

plr:WaitForChild("Deaths").Changed:Connect(function(value)
	textlabel.Visible = true
	if value == 1 then
		displayLivesLeft("Two more lives left.")
	elseif value == 2 then
		displayLivesLeft("One more life left")
	elseif value == 3 then
		displayLivesLeft(":)")
	end
end)

The reason for this is that you should NOT repeat yourself.

A very important programming principle is DRY. Don’t Repeat Yourself.

2 Likes

MemeFeedBot
for helping me
here is this free meme

1 Like

You should be using task.wait() instead of wait()

2 Likes

thank you for helping also : )

2 Likes