Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

player entered event wont trigger 2 values?

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by 6 years ago

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.

Ad

Answer this question