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

PlayerAdded script doesn't create GUI properties?

Asked by 10 years ago

I made a script that creates a GUI whenever a player enters the game.

function PlayerAdded(player)
    local screengui = Instance.new('ScreenGui', player.PlayerGui)
    local msg = Instance.new('TextLabel', screengui)
    msg.Text = Player.Name.." has entered the game! Welcome!"
    msg.Size = UDim2.new(0, 150, 0, 35)
    msg.Position = UDim2.new(0.5, -75, 0, 0)
    wait(5)
    screengui:Destroy()
end

for _, player in pairs(game.Players:GetPlayers()) do
    PlayerAdded(player)
end

game.Players.PlayerAdded:connect(PlayerAdded)

The problem is that the GUI is created WITHOUT the specified properties. So what is created is a ScreenGui with no size, position, or text. How do I fix this?

Also, it's worth noting that the GUI does not disappear.

1
Line 4 typo: "Player" should be "player" fahmisack123 385 — 10y

Answer this question