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

player entered event wont trigger 2 values?

I have a player entered event, and I want to display someone's name joining on a text gui and then have it fade out.

here's what i got so far that doesn't work

function playerAdded(player) --the event
	wait(.1)
	game.Lighting.Sound:Play()
	game.StarterGui.playerjoined.Frame.TextBox.Text = player.Name.. " has joined" -- the message
	wait(5)
	for i=0,1, .1 do
		game.StarterGui.playerjoined.Frame.TextBox.TextTransparency = (i) --the fade out
	end
end


game.Players.PlayerAdded:connect(playerAdded)

the code works, but it will never fade out or if I try changing the text instead of the text transparency it won't change

1 answer

Don’t use StarterGui when you want to change a GUI. StarterGui affects every player but it only takes effect when the player respawns or joins. Use something called PlayerGui instead.

Here’s a fixed script :

function playerAdded(player) --the event
    wait(.1)
    game.Lighting.Sound:Play()
    for i,v in pairs(game.Players:GetPlayers()) do
          v.PlayerGui.playerjoined.Frame.TextBox.Text = player.Name.. “has joined”
    end
    wait(5)
    for i=0,1, .1 do
        for i,v in pairs(game.Players:GetPlayers()) do
              v.PlayerGui.playerjoined.Frame.TextBox.TextTransparency = i
        end
    end
end


game.Players.PlayerAdded:connect(playerAdded)

Please note I made this script on mobile so I apologize if it doesn’t work or it looks weird, but you can use a for loop to get every player’s PlayerGui to change the GUI.

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