Setting a Decal

This is what im doing

imageProperty = "rbxassetid://" .. tostring(args[1])

I mean I did mention that Roblox is weird. Are there any errors?

1 Like

Nope, no errors are occuring, just the decal not appearing.

Is the decal’s face property assigned correctly?

1 Like

Yes, I’ve tested it in studio and in-game.

Weird thing for you to use tostring(...). Try changing it to a tonumber(...). IDs are numbers, not strings. :wink:

1 Like

It works fine for me, don’t think that’s the issue.

Also wait, I’ve just realized. Decal’s texture property requires a URL, and for some reason when you do it via scripts it doesn’t convert it into one. So tonumber() is pointless for this.

1 Like

That still did not work sadly…

I get your point, but the main deal here is that if they want to use args[1] as a number, the best practice is to alter tostring() to a tonumber() call.

1 Like

Try yeeting some debugging in your codes to see where the grand error is. Debugging is simple, just add print() statements in critical portions of the program.

1 Like

Well, there aren’t any errors, and I have chat message occur when the command function is completed running. And it shows the message every time, so the error is the decal not setting.

IDs are strings.

An example of an ID is rbxassetid://12345678. How would you add the rbxassetid:// without it being a string? The rest is a number, but the prefix isn’t. You can’t put strings into numbers, but you can put numbers into strings.

1 Like

You’re probably using the wrong ID.

Use the Decal ID. In this case, it is http://www.roblox.com/asset/?id=11201552325 or rbxassetid://11201552325.

1 Like

Heres the thing, the ‘rbxassetid://’ string is being concacenated with args[1] or in this case, 11201552325.

"rbxassetid://" .. args[1]

So after running your script, what is the Decal’s ‘Texture’ value?

2 Likes

Well, it would be rbxassetid://11201552339 but if I use the other one, it would be http://www.roblox.com/asset/?id=11201552325
But neither of them work.

What are the arguments (args) you are sending? I feel like there are a few cases where the script isn’t actually assigning an ID to your cursor depending on what you sent (such as where there are no arguments at all, or when imageProperty is nil, but the ExtraArg is a valid argument).

1 Like

The reason neither of these work is because you are sending a decal id, when rbxassetid:// doesn’t accepts decal ids. To fix this, replace your imageProperty = "rbxassetid://" .. tostring(args[1]) with imageProperty = "rbxthumb://type=Asset&id="..args[1].."&w=420&h=420".
Now, if you want to detect images AND decals, you can also check if ProductInfo.AssetTypeId equals 1 (as 1 is Image Ids), and then you can use your rbxassetid:// code.

1 Like

Thank you so much!! The decal finally appeared.

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