- What do you want to achieve?
So, I want it so that when I click a button it would display a small thumbnail size head image of the player on everyone's screen. This image would also have the name of the player. I want this image to be positioned in a certain location on the screen which has also been done.
- What is the issue?
The problem is, when the button is clicked I've managed to display an image, but the image that it displays is that of the local player. If one person clicks the button, it displays an image of each of the players on their own screen. What I want it to do is that when one player clicks the button on the Gui, an image of that exact client will show on every other screen, but it doesn't. I don't understand how I would do this with the code that I've got.
- What solutions have you tried so far?
I've already asked a question previously that was similar to this, but since I've asked the question my code has changed a lot. I've looked at every section I possibly could and still haven't found an answer.
Code:
Local script:
--local remoteFunction = game.ReplicatedStorage.remoteFunction
local pictureRemoteEvent = game.ReplicatedStorage.pictureRemoteEvent
--event for when the button is clicked to start the race and enter the player
script.Parent.readyToStart.MouseButton1Click:Connect(function(player)
pictureRemoteEvent:FireServer(player)
end)
--creating the image for all the players
pictureRemoteEvent.OnClientEvent:Connect(function()
--setting up the image label
print(player.Name)
--local remoteEventLocalPhoto = game.ReplicatedStorage.robloxLocalPhoto
local typingChallenge = player.PlayerGui.typingChallenge
local otherRacePosition = typingChallenge.otherRacePosition
local newImage = Instance.new("ImageLabel", otherRacePosition)
newImage.Name = player.Name
newImage.Position = UDim2.new(0, 0,0, 0)
newImage.Size = UDim2.new(0.06, 0,0.998, 0)
newImage.BackgroundTransparency = 1
-- setting the image label to the player's head
local UserId = player.UserId
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size100x100
local players = game:GetService("Players")
local content, isReady = players:GetUserThumbnailAsync(UserId, thumbType, thumbSize)
newImage.Image = content
end)
Server script:
local pictureRemoteEvent = game.ReplicatedStorage.pictureRemoteEvent
pictureRemoteEvent.OnServerEvent:Connect(function(player)
for _, player in pairs(game:GetService("Players"):GetPlayers()) do
pictureRemoteEvent:FireClient(player)
end
end)
