Any reason why the decal isn't loading via scripting?

Before:

After:

image

My goal is for users to able to change posters using an roblox asset id, when I put an decal/asset id that ACTUALLY works, it doesn’t work and gives me a blank part.

This is what I get in console:

 15:03:01.014  Client extracted assetId: 144526825  -  Client - LocalScript:26
  15:03:01.030  Server received assetId: 144526825  -  Server - Script:26
  15:03:01.030  Decal Texture before http://www.roblox.com/asset/?id=13443762237  -  Server - Script:30
  15:03:01.030  Setting Decal.Texture to: http://www.roblox.com/asset/?id=144526825  -  Server - Script:31
  15:03:01.030  Decal Texture now http://www.roblox.com/asset/?id=144526825  

Scripts (SERVER SIDED)

local ProximityPrompt = script.Parent
local Part = ProximityPrompt.Parent
local Decal = Part:FindFirstChildOfClass("Decal")
local MarketplaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local RemoteEvent = ReplicatedStorage:WaitForChild("PosterChangeRequest")
local GamepassId = 1197662713

local function ownsGamepass(player)
	local success, result = pcall(function()
		return MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassId)
	end)
	return success and result
end

ProximityPrompt.Triggered:Connect(function(player)
	if ownsGamepass(player) then
		RemoteEvent:FireClient(player)
	else
		player:Kick("You need the Gamepass to change posters!")
	end
end)

RemoteEvent.OnServerEvent:Connect(function(player, assetId)
	print("Server received assetId:", assetId)

	if tonumber(assetId) and Decal then
		local texture = "http://www.roblox.com/asset/?id=" .. assetId
		print('Decal Texture before', Decal.Texture)
		print("Setting Decal.Texture to:", texture)
		Decal.Texture = texture
		
		print('Decal Texture now', Decal.Texture)
	end
end)

Local Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("PosterChangeRequest")
local Players = game:GetService("Players")
local player = Players.LocalPlayer

RemoteEvent.OnClientEvent:Connect(function()
	local gui = Instance.new("ScreenGui")
	gui.ResetOnSpawn = false
	gui.Name = "AssetPrompt"

	local textbox = Instance.new("TextBox")
	textbox.Size = UDim2.new(0, 200, 0, 50)
	textbox.Position = UDim2.new(0.5, -100, 0.5, -25)
	textbox.PlaceholderText = "Enter Image Asset ID"
	textbox.Text = ""
	textbox.ClearTextOnFocus = true
	textbox.Parent = gui

	gui.Parent = player:WaitForChild("PlayerGui")

	textbox.FocusLost:Connect(function(enterPressed)
		if enterPressed then
			local rawText = textbox.Text
			local assetId = rawText:match("%d+") -- Extract number only

			print("Client extracted assetId:", assetId)

			if assetId then
				RemoteEvent:FireServer(assetId)
			end
			gui:Destroy()
		end
	end)
end)

you cant load decal
You need Image ID
If you want to get Image ID in a runtime consider using InsertService | Documentation - Roblox Creator Hub
And you may use AssetService | Documentation - Roblox Creator Hub to check type of a id

1 Like

Thanks, it works now!

1 Like