Why won't my script clone?

  1. What do you want to achieve?
    I am trying to show the players face onto an ImageLabel that is created in the script.
  2. What is the issue?
    The script won’t clone the ImageLabel and it only changes certain properties.
  3. What solutions have you tried so far?
    I wrote a bunch of prints after every line and they all print. Also there are no errors. The only property that changes is the BackgroundTransparency property. The script is a local script.

Code

local Event = game.ReplicatedStorage.Events.CreateLobby
local Players = game.Players
local plr = Players.LocalPlayer

Event.OnClientEvent:Connect(function(Owner)
	print("3")
	print(Owner)
	local CharacterImage = script.Parent.Sample:Clone()
	print("3.1")
	CharacterImage.Name = Owner
	print("3.2")
	CharacterImage.BackgroundTransparency = 0
	print("3.3")
	CharacterImage.Image = Players:GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.AvatarBust, Enum.ThumbnailSize.Size420x420)
	print("3.4")
end)

You have to parent the image after you clone it.

1 Like

You need to parent what you cloned, try this:

local Event = game.ReplicatedStorage.Events.CreateLobby
local Players = game.Players
local plr = Players.LocalPlayer

Event.OnClientEvent:Connect(function(Owner)
print(“3”)
print(Owner)
local CharacterImage = script.Parent.Sample:Clone()
print(“3.1”)
CharacterImage.Name = Owner
print(“3.2”)
CharacterImage.BackgroundTransparency = 0
print(“3.3”)
CharacterImage.Image = Players:GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.AvatarBust, Enum.ThumbnailSize.Size420x420)
print(“3.4”)
CharacterImage.Parent = --Where you want the clone to be. I’m guessing the frame of the imagelabel that you stated in your post.
end)

It works, but the sample image that I am cloning is becoming visible and I can’t turn it invisible in studio manually nor in the script.

If you want to turn it invisible through the script then:

CharacterImage.Visible = false

The “CharacterImage” is the variable you created, which is the cloned sample. So therefore that line sets it’s visibility to false, and if you wanted to make it visible once more, you’d replace the false with true. Hope this helps.

1 Like

It’s not the cloned sample that I’m having the problem with, the invisible sample that I am using to generate the players image is turning visible (the correct label is also visible) and I can’t make it invisible. When I try to turn it invisible in a script it doesn’t turn invisible and when I try manually setting it to invisible in the properties menu it does nothing.

Could I perhaps see a picture of your StarterGui? There may be a problem with the way you arranged the contents in it.

1 Like