Unable to load mesh through script

I’m trying to make an effect that shows the number that represents the side of a dice that it rolled on, but I’m having trouble loading my mesh.

I get this error:

Unable to cast string to int64

when I try doing:

local diceMeshPart = game:GetService("InsertService"):LoadAsset(diceMeshes["Dice"..diceNumber])

To get the mesh that represents the dice number through a table called “diceMeshes”

local diceMeshes = {
	["Dice1"] = "rbxassetid://15018583116";
	["Dice2"] = "rbxassetid://15018675695";
	["Dice3"] = "rbxassetid://15018771597";
	["Dice4"] = "rbxassetid://15018783827";
	["Dice5"] = "rbxassetid://15018789818";
	["Dice6"] = "rbxassetid://15018802033"
}

How can I fix this?

:LoadAsset() is looking for a number, but your dictionary has strings in it.

Just remove the rbxassetid:// and the quotations from each one.

local diceMeshes = {
	["Dice1"] = 15018583116,
	["Dice2"] = 15018675695,
	["Dice3"] = 15018771597,
	["Dice4"] = 15018783827,
	["Dice5"] = 15018789818,
	["Dice6"] = 15018802033,
}
2 Likes

InsertService:LoadAsset() takes in the asset Id as a number (64 bit integer is the specific type according to the log). Change your record to contain numbers:

local diceMeshes = {
	["Dice1"] = 15018583116,
	["Dice2"] = 15018675695,
	["Dice3"] = 15018771597,
	["Dice4"] = 15018783827,
	["Dice5"] = 15018789818,
	["Dice6"] = 15018802033
}
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.