✓ Accepted answer
EDIT I answered too soon!
There's a few more things we need to change.
GetPlayerFromCharacter is a method of the Players service, not hit.Parent (that's the character). UserId is a property of the player, NOT the character. You pass in the string "Humanoid" whereas we need to pass in the parent of the object (say a leg or an arm) which is the character.
Here is the wiki article on player UserId's.
local players = game:GetService("Players")
function onTouched(hit)
local player = players:GetPlayerFromCharacter(hit.Parent)
if player then
local userid = player.UserId
game.Workspace.LocalUserId.Value = userid
wait(0.1)
game.Workspace.join.SurfaceGui.ImageLabel.Image =('http://www.roblox.com/Thumbs/Avatar.ashx?x=420&y=420&Format=Png&userId='..userid)
end
end
script.Parent.Touched:connect(onTouched)
In order to append or concatenate strings in lua you want to use the .. operator.
Here's how you do that with your code.
game.Workspace.join.SurfaceGui.ImageLabel.Image =('http://www.roblox.com/Thumbs/Avatar.ashx?x=420&y=420&Format=Png&userId='..userid)
Some examples.
print("my ".."name is ".."kools")
local var = 3
print("# is "..var)
2 comments
Thank you for helping me with this. The gui works well. Is there any other decals like this one. What I mean is, any other URL based decals, and not just user images?
You can also get images of certain assets like catalog items. It is mentioned in this scriptinghelper post. https://scriptinghelpers.org/questions/30716/how-do-you-get-an-items-image-in-game