Cloning a image and setting image to user image, only working when playing alone

Hello. Im making a script that displays every players character in the game on a image but for some reason the code breakes when two players load in.

It is in a server script Serverscript location is ServerScriptService

Here is my script:

local template = game.Workspace.StartRoom.Build.Elevator.BillGui:WaitForChild("BillboardGui").Players.Template
local sound = game.Workspace.StartRoom.Build.Elevator:WaitForChild("PlayerEnter")

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		sound:Play()

		local userId = player.UserId
		local thumType = Enum.ThumbnailType.AvatarBust
		local thumSize = Enum.ThumbnailSize.Size420x420
		local content = game.Players:GetUserThumbnailAsync(userId, thumType, thumSize)

		local clone = template:Clone()
		clone.Visible = true
		clone.Image = content
		clone.Name = player.Name
		clone.Parent = game.Workspace.StartRoom.Build.Elevator.BillGui:WaitForChild("BillboardGui").Players
	end)
end)
2 Likes

Well, yeah. Whenever a player dies, it’s creating a new image for all the players on the server. You are going to want to put this in a LoacalScript.

but i want it to show for everyone

simply fire a remote event to the server!

for example inside a local script

local event = game.ReplicatedStorage.Event
event:Fireserver

inside a server script

game.ReplicatedStorage.Event.OnServerEvent:Connect(function()

–do stuff

end)

but if its in a local script it will only show for the client not everyone.

you send the info to a server script and create it in the server script.