Problem with getting attribute from model

  1. What do you want to achieve? Keep it simple and clear!
    So basically i have map voting script which gets ImageID from model attribute

  2. What is the issue? Include screenshots / videos if possible!
    I’m getting an error here is screenshot:

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub? I was making this by youtube video, but this didn’t work.

Here is code which gets ImageID

local VotingFrame = script.Parent:WaitForChild("Frame")

local currentVote = nil

if game.ReplicatedStorage.Values.VotingProgress == true then workspace.RemoteEvents.PlaceVote:FireServer() end

game.ReplicatedStorage.Values.VotingProgress:GetPropertyChangedSignal("Value"):Connect(function()
	currentVote = nil
	VotingFrame.Visible = game.ReplicatedStorage.Values.VotingProgress.Value
end)

game.Workspace.RemoteEvents.UpdateVotingSystem.OnClientEvent:Connect(function(data)
	for i, button in pairs(VotingFrame:GetChildren()) do
		for x,map in pairs(data) do
			if button:IsA("ImageButton") and map.order == button.LayoutOrder then
				if game.ReplicatedStorage.Maps:FindFirstChild(map.name) then
					
					local mapInfo = game.ReplicatedStorage.Maps:FindFirstChild(map.name)
					
				button.MapName.Text = map.name
				button.Votes.Text = #map.players
				button.Image = "rbxassetid://"..mapInfo:GetAttribute("ImageID") -- here is getting ImageID
					
				if currentVote == map.order then
					button.UIStroke.Color = Color3.new(1, 1, 1)
				else
					button.UIStroke.Color = Color3.new(0, 0, 0)
				end
				
				button.MouseButton1Click:Connect(function()
					if game.ReplicatedStorage.Values.VotingProgress.Value == true then
						if currentVote == nil or currentVote ~= button.LayoutOrder then
							currentVote = button.LayoutOrder
							
							game.Workspace.RemoteEvents.PlaceVote:FireServer(currentVote)
						end
					end
				end)
				end
			end
		end
	end
end)

The error your getting is basically saying the Attribute your trying to read doesn’t exist (it’s nil) - Check that the spelling is correct.

tostring the thingy

if mapInfo:GetAttribute("ImageID")) then
	button.Image = "rbxassetid://" .. tostring(mapInfo:GetAttribute("ImageID"))
else 
	print("no ImageID")
end

image
EDIT: Oh freak, i had ImadeID

EDIT2: Other Error

Alright nvm, so it now works, but
image
There is just no image, it doesn’t show.

Should i use roblox.com.library?

Alright so i used roblox.com/library/, but got same result.

Sorry for bump, but still no work

What’s the Image ID that you want the button to show (link?) Also, try printing the new ImageID and see what it says.

One of ID.

Have you printed the new ID? And what does it say?

NewID? Don’t understand (30 letters)

if mapInfo:GetAttribute("ImageID")) then
	button.Image = "rbxassetid://" .. tostring(mapInfo:GetAttribute("ImageID"))
	print("image id:" .. button.Image) -- < This.
else 
	print("no ImageID")
end

Exactly image id is right (30 letters)

Sorry for bump, but it should freaking work.

try

rbxassetid://"..(mapInfo:GetAttribute("ImageID"):gsub('[^%d+]','')

this removes everything but numbers from the attribute

wdym


image

forgot " at the beginning:

"rbxassetid://"..(mapInfo:GetAttribute("ImageID"):gsub('[^%d+]','')