You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I just want to figure out how to make the texture from a tool appear in an image.
In my current code, the image always shows as nil. But what I actually want is: when a player gives me an item, the image (or icon/texture) of that item should appear.
I’ve tried several other approaches but failed. Is there any solution to fix this?
Any help would be greatly appreciated. Thank you!
RemoteEvent.OnClientEvent:Connect(function(fromPlayer, toolName)
frame.Visible = true
nameLabel.Text = fromPlayer.Name .. " Give" .. toolName
local character = player.Character
local tool = character:FindFirstChildOfClass("Tool")
if toolName and toolName.TextureId then
fotoItem.Image = toolName.TextureId
else
fotoItem.Image = "rbxassetid://0"
end
local thumbnail, ready = Players:GetUserThumbnailAsync(
fromPlayer.UserId,
Enum.ThumbnailType.HeadShot,
Enum.ThumbnailSize.Size100x100
)
if ready then
fotoKtp.Image = thumbnail
end
yesBtn.MouseButton1Click:Connect(function()
MengonfirmasiGiveBangKu:FireServer(fromPlayer, toolName, true)
task.wait(0.5)
frame.Visible = false
end)
noBtn.MouseButton1Click:Connect(function()
MengonfirmasiGiveBangKu:FireServer(fromPlayer, toolName, false)
frame.Visible = false
end)
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
could you share if the image is being set to rbxassetid://0 or nothing? because if its being set to rbxassetid://0 that means your tool just doesnt have a texture, and if its being set to nothing then something went wrong when assigning .image
@athony2025 Your previous comment (before you edited your messsage) was right.
You are trying to index a property called TextureId from the toolName, which, I assume, is a string name of the tool’s name, which is not exactly right. You want to get the received Tool instance to index the TextureId property.
Oh, I see! That makes sense — I was using toolName as a string instead of the actual Tool instance.
So I should first get the Tool object (the one the player gives me), and then use .TextureId from that Tool, right?
Thanks for clarifying!
-- instead of this:
fotoItem.Image = toolName.TextureId
-- do this:
fotoItem.Image = tool.TextureId -- where "tool" is the actual Tool instance
You could use the tool’s TextureID for the Hotbar as the texture for the GUI ImageLabel.
local player = game:GetService("Players").LocalPlayer
local tool = player:WaitForChild("Backpack")
:WaitForChild("Pizza")
local textueId = tool.TextureId
local imageLabel = script.Parent --test script in the ImageLabel
imageLabel.Image = textueId --tool.TextureId to the ImageLabel.Image
If you’re using a transparent background on the tools.TextureId.. even better. (maybe)
You could also put the tool or model inside a ViewportFrame..
Set up a Camera and the ViewportFrame will render it directly to the GUI ImageLabel.
This is pretty sweet, as you can get nice angles on the 3D object for the ImageLabel.
Testing..
Simple GUI, Path: StarterGui.ScreenGui.Frame.ImageLabel
Using the tool: Pizza Tool, ID 14002773553
LocalScript in the ImageLabel..
local player = game:GetService("Players").LocalPlayer
local tool = player:WaitForChild("Backpack"):WaitForChild("Pizza")
local frame = player.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("Frame")
local imageLabel = frame:WaitForChild("ImageLabel")
local viewport = Instance.new("ViewportFrame")
viewport.Size = UDim2.new(1,0,1,0)
viewport.Position = UDim2.new(0,0,0,0)
--viewport.BackgroundTransparency = 1
viewport.Parent = imageLabel
local camera = Instance.new("Camera") camera.FieldOfView = 25
camera.CFrame = CFrame.new(Vector3.new(2,2,2), Vector3.new(0,0,0))
viewport.CurrentCamera = camera
local cloneTool = tool:Clone() cloneTool.Parent = viewport
cloneTool.Handle.CFrame = CFrame.new(0,0,0) * CFrame.Angles(math.rad(-15), math.rad(35), 0)