Hi, I'm trying to make a horror game and I want a television to show the local player's image. I have tried several blocks of code to make this happen, but the image is always transparent. I am aware of the fact that the following code blocks are messy and unorganized, but I was in a rush to complete them. These codes include: 1:
-- this one was in a block that starts the television change when touched. I cut out a lot of the --initial code to shorten it. It's in a default script. local debounce = false script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild('Humanoid') then if not debounce then debounce = true local hi = game.Players[hit.parent.Name] game.Workspace.Telly.Screen.Image.ImageLabel="http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username="..hi
2:
--this one I put inside the television itself's screen. I tried it with and without being inside a --normal and a local script. local player = game.Players.LocalPlayer.Name function update() script.Parent.Image= "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username="..player end update()
3:
--this one is the same as the above, but using the UserId instead of the username. It still --doesn't work. Once again, tried local and default scripts. local player = game.Players.LocalPlayer.UserId function update() script.Parent.Image= "https://web.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&userid="..player end update()
4:
--at this point, i had run out of ideas. This was my last-ditch effort attempt. script.Parent.Image= "https://web.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&userid="..game.Players.LocalPlayer.UserId
I don't what's wrong with these scripts. Please help me fix it.
For this purpose you should use the GetUserThumbnailAsync function of the players service. which allows you to get one of 3 types of Thumbnails of the player, those being:
They can also be one of 7 thumbnail sizes, those being:
With that said the Function itself takes in 3 parameters, the player's UserId, the thumbnail type, and the thumbnail size, like:
Players:GetUserThumbnailAsync(UserId,ThumbnailType,ThumbnailSize)
Which can be put into application like this:
--localscript local players = game:GetService("Players") local plr = players.LocalPlayer script.Parent.Image = players:GetUserThumbnailAsync(plr.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size180x180)
In this instance, you would have to set the parent of the localscript to the imagelabel/imagebutton you want to modify
Hopefully this helped! Be sure to accept if it did!