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

How to make an image of the player who joined at the top of the screen, kind of like in arsenal?

Asked by 4 years ago

When I try to add the image, the image doesnt appear but it is getting created, here is my script:

game.Players.PlayerAdded:Connect(function(plr)
    local thumbType = Enum.ThumbnailType.HeadShot
    local thumbSize = Enum.ThumbnailSize.Size150x150
    local playerThumbnail = game.Players:GetUserThumbnailAsync(plr.UserId, thumbType, thumbSize)

    local newImage = Instance.new("ImageLabel", game.StarterGui.Leaderboard.Frame)
    newImage.Name = plr.Name.."Image"
    newImage.Position = UDim2.new(0.5, 0, 0.5, 0)
    newImage.Size = UDim2.new(0, 150, 1, 0)
    newImage.AnchorPoint = Vector2.new(0.5, 0.5)
    newImage.Image = playerThumbnail
end)

1 answer

Log in to vote
0
Answered by 4 years ago

When you put things in StarterGui before clicking Play (With Player), it will immediately replicate to the PlayerGui. The PlayerGui is the reason the player sees the GUI to begin with. So instead of using the StarterGui, you need to put it in the PlayerGui.

game.Players.PlayerAdded:Connect(function(plr)
    local thumbType = Enum.ThumbnailType.HeadShot
    local thumbSize = Enum.ThumbnailSize.Size150x150
    local playerThumbnail = game.Players:GetUserThumbnailAsync(plr.UserId, thumbType, thumbSize)

    local newImage = Instance.new("ImageLabel")
    newImage.Parent = plr.PlayerGui
    newImage.Name = plr.Name.."Image"
    newImage.Position = UDim2.new(0.5, 0, 0.5, 0)
    newImage.Size = UDim2.new(0, 150, 1, 0)
    newImage.AnchorPoint = Vector2.new(0.5, 0.5)
    newImage.Image = playerThumbnail
end)
0
also, don't use the 2nd parameter of Instance.new() as it is deprecated and slow. Dovydas1118 1495 — 4y
0
OMG thank you so much! :D Scryptol 2 — 4y
0
Mark it as the answer then. Dovydas1118 1495 — 4y
Ad

Answer this question