Can you help me with a script?

Hiya Developers!

Just a quick question, does anyone know how i would check when a player hit a part, then enter the Players UserID in a Decal Texture?

Touched and Player Thumbnail

Note that there might be a better method for getting the player thumbnail. It is not the players User Id tho

hmmm…

Untitled

script:

script.Parent.Touched:Connect(function(Touched) 
	
	local Humanoid = Touched.Parent:FindFirstChildWhichIsA("Humanoid") -- Finding the humanoid on every parent does the touched parent on
	
	if Humanoid then -- Finding out if its humanoid
		
		local Character = Humanoid.Parent -- Getting the character by its humanoid children
		
		local Player = game.Players:GetPlayerFromCharacter(Character) -- Getting the player owner of the character
		
		local Id = Player.UserId -- Getting the player's id
		local PlayerThumbnail = game.Players:GetUserThumbnailAsync( -- Getting the player thumbnail
			
			Id, -- UserId
			Enum.ThumbnailType.HeadShot, -- Thumbnail type
			Enum.ThumbnailSize.Size420x420 -- Thumbnail size
			
		)
		script.Parent.Decal.Texture = PlayerThumbnail -- Apply	
		
		print("Your Thumbnail Is Loaded") -- Just for sure 
	end
end)

Thanks so much, this has worked :slight_smile: