So, I’m building a plugin with preset codes to insert, but I can’t figure out how to insert the custom code. I’m trying to achieve it by using “rbxassetid” but how would I get the asset into the game? Here’s my code:
local toolBar = plugin:CreateToolbar("Sloppy's Preset Codes", "Hm", "rbxassetid://9772232203")
local newButton = toolBar:CreateButton("Two Variable Currency Leaderstats", "Inserts a custom two variable currency script with datastores. NOTICE: API SERVICE MUST BE ON IN ORDER TO WORK.", "rbxassetid://9772232203")
newButton.Click:Connect(function()
local newAsset = Instance.new("rbxassetid://9772048895")
newAsset.Parent = game.ServerScriptService
end)
You’d use InsertService:LoadAsset to insert something like a model. However, the model needs to be available for anyone to take. If the model is not available, calling the method will error with something like “HTTP 403 (Forbidden)”. In your snippet, it’d be implemented something like:
local toolBar = plugin:CreateToolbar("Sloppy's Preset Codes", "Hm", "rbxassetid://9772232203")
local newButton = toolBar:CreateButton("Two Variable Currency Leaderstats", "Inserts a custom two variable currency script with datastores. NOTICE: API SERVICE MUST BE ON IN ORDER TO WORK.", "rbxassetid://9772232203")
newButton.Click:Connect(function()
local InsertService = game:GetService("InsertService")
local success, result = pcall(InsertService.LoadAsset, InsertService, 9772048895)
if success then
result.Parent = game:GetService("ServerScriptService")
else
warn("Something went wrong with loading the asset! "..result)
end
end)
Well neither work it would seem I get this error:
Unable to create an Instance of type "rbxassetid://9772048895"
Oh, I’m so sorry! I forgot to update it after I made the change.