-- // VARIABLES // -- local Utilities = {} Utilities.DELETED_MARKER = {} -- | Obfuscation Constants | -- local OBFUSCATED_KEY_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" local OBFUSCATED_KEY_LENGTH = 24 -- // FUNCTIONS // -- function Utilities.GetOrCreateRemote(parent: Instance, className: string, name: string): RemoteEvent | RemoteFunction | Folder local existing = parent:FindFirstChild(name) if existing and existing:IsA(className) then return existing end if existing then existing:Destroy() end local newInstance: RemoteEvent | RemoteFunction | Folder if className == "RemoteEvent" then newInstance = Instance.new("RemoteEvent") elseif className == "RemoteFunction" then newInstance = Instance.new("RemoteFunction") elseif className == "Folder" then newInstance = Instance.new("Folder") else error(`[DataReplicator | Utilities] Invalid className '{className}' passed to GetOrCreateRemote`) end newInstance.Name = name newInstance.Parent = parent return newInstance end function Utilities.GenerateObfuscatedKey(): string local key = {} local numChars = #OBFUSCATED_KEY_CHARS for _ = 1, OBFUSCATED_KEY_LENGTH do local randomIndex = math.random(numChars) key[#key + 1] = string.sub(OBFUSCATED_KEY_CHARS, randomIndex, randomIndex) end return table.concat(key) end return table.freeze(Utilities)