I’ve been working on a building game that has commands, similar to blockate. I’ve been trying to make a command that creates decals onto a block’s surface. So far, I’ve got the function working, but the decal (the id is 11201552339) would not set itself.
I’ve tried rbxassetid:// and http://www.roblox.com/asset/?id=, but both of them did NOT work at all.
My current code:
--// Services
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local MarketPlaceService = game:GetService("MarketplaceService")
--// Variables
local Events = ReplicatedStorage:WaitForChild("Events")
local CommandsEvent = Events:WaitForChild("Commands")
local CommandMessage = CommandsEvent:WaitForChild("CommandMessage")
local ExtraArguments = {
"rotation",
}
local module = {}
function module.init(player, args)
if args then
local ExtraArg = nil
local imageProperty = nil
if tonumber(args[1]) then
local ProductInfo = MarketPlaceService:GetProductInfo(tonumber(args[1]))
if ProductInfo and ProductInfo.AssetTypeId == 13 then
imageProperty = "rbxassetid://" .. args[1]
end
else
if not table.find(ExtraArguments, string.lower(args[1])) then
local userId = game.Players:GetUserIdFromNameAsync(args[1])
if userId then
local imageContent = game.Players:GetUserThumbnailAsync(userId, Enum.ThumbnailType.AvatarBust, Enum.ThumbnailSize.Size352x352)
imageProperty = imageContent
end
else
ExtraArg = string.lower(args[1])
end
end
if ExtraArg == nil then
if imageProperty ~= nil then
local mouseTarget = Events.GetTarget:InvokeClient(player, "target")
if mouseTarget then
local mouseSurface = Events.GetTarget:InvokeClient(player, "targetsurface")
if mouseSurface then
CommandMessage:FireClient(player, "SUCCESSFULLY MADE DECAL!")
if mouseTarget:FindFirstChild(mouseSurface.Name) then
mouseTarget[mouseSurface.Name].Decal.Texture = imageProperty
else
local clone = mouseTarget:Clone()
clone.Name = mouseSurface.Name
clone.Parent = mouseTarget
clone.CanCollide = false
clone.CanQuery = false
clone.Transparency = 1
local inst = Instance.new("Decal")
inst.Face = Enum.NormalId[mouseSurface.Name]
inst.Texture = imageProperty
inst.Parent = clone
end
end
end
end
else
if ExtraArg == "rotation" then
print(args[2])
if args[2] and tonumber(args[2]) then
local mouseTarget = Events.GetTarget:InvokeClient(player, "target")
if mouseTarget then
local mouseSurface = Events.GetTarget:InvokeClient(player, "targetsurface")
if mouseSurface then
if mouseTarget:FindFirstChild(mouseSurface.Name) then
mouseTarget[mouseSurface.Name].CFrame *= CFrame.Angles(0, math.rad(args[2]), 0)
end
end
end
end
end
end
end
end
return module
If you are attempting to help me, please include explanations.