Decal changing script not working

Hi, I’m making a script that changes the decal by the text of a text box, but it’s not working and just shows up: 11:21:48.872 - Image "https://assetdelivery.roblox.com/v1/asset?id=5534886676" failed to load in "Workspace.Decal.Decal.Texture": Request failed

Here’s the code:

script.Parent.Sub.MouseButton1Click:Connect(function()
	if script.Parent.TextBox.Text then
		local textbox = script.Parent.TextBox.Text
		game.Workspace.Decal.Decal.Texture = "http://www.roblox.com/asset/?id="..textbox
	end
end)
2 Likes

Try using “rbxassetid://” instead of “http://www.roblox.com/asset/?id=

Okay, thanks I’ll use it, sorry I was away from keyboard

Nope still not working what to do now?

so, I’d have to access the script from a different account?

Ignore what I just said, you are the owner so it should be working. Try using a different ID and see if it works, if it does then its a problem with the ID

Oh okay, I will try try it. hope it works

I tried another link but it still gives me an error: 12:07:23.601 - Image "https://assetdelivery.roblox.com/v1/asset?id=3708716595" failed to load in "Workspace.Decal.Decal.Texture": Request failed

I think the problem is that you need the Asset ID and not the ID from the Roblox Library, try using this:

game:GetService("MarketplaceService"):GetProductInfo(textbox).AssetId
2 Likes

Okay, here’s an error message: 12:13:06.214 - Image "5534927340" failed to load in "Workspace.Decal.Decal.Texture": Unexpected URL

Make sure you’re still using “rbxassetid://” before the number, and if that still doesn’t work try this: Reliably getting an asset ID from a decal ID - #6 by H_mzah

So, will the final code look like this?

	if script.Parent.TextBox.Text then
		local textbox = script.Parent.TextBox.Text
		game.Workspace.Decal.Decal.Texture = "rbxassetid://"..game:GetService("MarketplaceService"):GetProductInfo(textbox).AssetId
	end
end)

Yeah, thats correct. If it works then you should be receiving the asset id 5534886654

Yeah it works but, no error, and it’s not displaying the decal.

That’s unusual, you may want to try the other solutions in this thread: Reliably getting an asset ID from a decal ID

You may simply just want to edit the transparency of the decal. For instance, if you click, you would set the original decal’s transparency to 1 and the new decal’s transparency to 0. In this case, both decals would already be on the model.

Roblox tends to be weird with these types of things, but this is what I would do. I’m sure there’s a better way out there, however. Hope this helps.