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

Why is my Gui not becoming less transparent and showing my text?

It prints this in the Output "ScreenGui is not a valid member of PlayerGui", when ScreenGui clearly is a child of PlayerGui! Here's the script:

game.Players.PlayerAdded:connect(function(plr)
    local name = plr.Name	
	local gui = plr.PlayerGui.ScreenGui.TextLabel
    gui.BackgroundTransparency = 0.9
    wait(0.01)
    gui.BackgroundTransparency = 0.8
    wait(0.01)
    gui.BackgroundTransparency = 0.7
    wait(0.01)
    gui.BackgroundTransparency = 0.6
    wait(0.01)
    gui.BackgroundTransparency = 0.5
    wait(0.01)
	gui.Text = name .. "has entered the game!"
end)

1 comment

0

I have made some edits to my answer, improving it.

1 answer

✓ Accepted answer

The problem is that the GUI may not have loaded when the event fires. To fix this, use :WaitForChild()

game.Players.PlayerAdded:connect(function(plr)
	local name = plr.Name   
	local gui = plr.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("TextLabel") --// the problem gets fixed here
	for i = 0.1,0.5,0.1 do
		gui.BackgroundTransparency = i
		wait(0.01)
	end
	gui.Text = name .. "has entered the game!"
end)

Edit:

I have optimised your script a bit, the main change being the for loop; it makes it much faster to accomplish what you want to do.

For loops like the one I am using have a third parameter, it being the 'step' (defaulting to 1). This script will run from 0.1 to 0.5 increasing by 0.1 every time.


Tip:

Use Tab, not Space. Space is inconsistent and thus very annoying.


As a side note, this script only shows the player joined notification on the player that joined; therefore this feature is mostly obsolete, at least for what it is normally used for.

If you want, I can expand my answer and break the solution down for you?


Hope I helped!

~TDP

3 comments

0

You accidentally put a "[" in the end of the script. Other than that, thank you.

0

Why are you not using a for loop?

0

Ah, I overlooked that. I was fixing the main problems - and was rushing a bit.

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