How to Create a temporary id?

I am trying to create a paint plugin that will create a temporary id that can be used to export the masterpiece that the user has created.

I created this script but when I ran it, it did nothing:

local Masterpiece = game.workspace.masterpiece
local TempID = Masterpiece:GetTemporaryId()
print(TempID)

Is this how you are suppose to do this?

1 Like

You could use GenerateGUID: HttpService | Documentation - Roblox Creator Hub
Example code:

local HttpService = game:GetService("HttpService")
local Result = HttpService:GenerateGUID(true)
print(Result) --// Example from dev hub: {04AEBFEA-87FC-480F-A98B-E5E221007A90}

I hope this helps you.

2 Likes

That script would likely produce this error: GetTemporaryId is not a valid member of ModuleScript (or something)

If masterpiece is some kind of module script you have to require() it.

If you want to get an unique id, you can use HttpService:GenerateGUID()

If you are asking for the structure of a paint masterpiece plugin, I would do:

--module
local methods = {}
methods.__index = methods
methods.GetTemporaryId= function(self)
    return "abcdef"
end
return {new=function()
    local masterpiece = setmetatable({}, methods)
    return masterpiece
end}
--script
local Masterpiece = require(workspace.masterpiece).new()
local id = Masterpiece:GetTemporaryID()
print(id)
2 Likes