Skip to content

Types

To ensure compatibility with Roblox DataStore, Roda only supports primitive data types (strings, numbers, booleans).

This section offers some basic examples of converting primitives into complex Roblox types.

Color3

Script
local colors = require(game.ReplicatedStorage.Colors)   -- Adjust as needed
local items = require(game.ReplicatedStorage.Items)     -- Adjust as needed

for _, item in pairs(items) do    
    local colorData = colors[item.colorKey] or error("Color not found: " .. item.colorKey)

    item.color = Color3.fromRGB(colorData.R, colorData.G, colorData.B) 
end
ModuleScript
local items = {
    {
        id = 1,
        colorKey = "orange",
        -- ..
    },
}

return items
ModuleScript
local colors = {
    ["orange"] = {
        colorKey = "orange",
        R = 255,
        G = 176,
        B = 0,
    },
}

return colors

Vector3

Script
local positions = require(game.ReplicatedStorage.Positions) -- Adjust as needed
local items = require(game.ReplicatedStorage.Items)         -- Adjust as needed

for _, item in pairs(items) do    
    local pos = positions[item.posKey] or error("Position not found: " .. item.posKey)

    item.position = Vector3.new(pos.X, pos.Y, pos.Z)
end
ModuleScript
local items = {
    {
        id = 1,
        posKey = "startPosition",
        -- ..
    },
    {
        id = 2,
        posKey = "endPosition",
        -- ..
    },
}

return items
ModuleScript
local positions = {
    ["startPosition"] = {
        posKey = "startPosition",
        X = 10,
        Y = 5,
        Z = 0,
    },
    ["endPosition"] = {
        posKey = "endPosition",
        X = 15,
        Y = 8,
        Z = 0,
    },
}

return positions

Vector2

Script
local sizes = require(game.ReplicatedStorage.Sizes)      -- Adjust as needed
local items = require(game.ReplicatedStorage.Items)      -- Adjust as needed

for _, item in pairs(items) do    
    local sizeData = sizes[item.sizeKey] or error("Size not found: " .. item.sizeKey)

    item.size = Vector2.new(sizeData.X, sizeData.Y) 
end
ModuleScript
local items = {
    {
        id = 1,
        sizeKey = "uiSize",
        -- ..
    },
    {
        id = 2,
        sizeKey = "iconSize",
        -- ..
    },
}

return items
ModuleScript
local sizes = {
    ["uiSize"] = {
        sizeKey = "uiSize",
        X = 50,
        Y = 100,
    },
    ["iconSize"] = {
        sizeKey = "iconSize",
        X = 30,
        Y = 30,
    },
}

return sizes

UDim2

Script
local uiSizes = require(game.ReplicatedStorage.UISizes) -- Adjust as needed
local items = require(game.ReplicatedStorage.Items)     -- Adjust as needed

for _, item in pairs(items) do    
    local sizeData = uiSizes[item.sizeKey] or error("UISize not found: " .. item.sizeKey)

    item.size = UDim2.new(sizeData.ScaleX, sizeData.OffsetX, sizeData.ScaleY, sizeData.OffsetY) 
end
ModuleScript
local items = {
    {
        id = 1,
        sizeKey = "buttonSize",
        -- ..
    },
    {
        id = 2,
        sizeKey = "panelSize",
        -- ..
    },
}

return items
ModuleScript
local uiSizes = {
    ["buttonSize"] = {
        sizeKey = "buttonSize",
        ScaleX = 0.5,
        ScaleY = 0.5,
        OffsetX = 0,
        OffsetY = 0,
    },
    ["panelSize"] = {
        sizeKey = "panelSize",
        ScaleX = 0.8,
        ScaleY = 0.8,
        OffsetX = 0,
        OffsetY = 0,
    },
}

return uiSizes

UDim

Script
local uiScales = require(game.ReplicatedStorage.UIScales)   -- Adjust as needed
local items = require(game.ReplicatedStorage.Items)         -- Adjust as needed

for _, item in pairs(items) do    
    local scaleData = uiScales[item.scaleKey] or error("UIScale not found: " .. item.scaleKey)

    item.size = UDim.new(scaleData.Scale, scaleData.Offset) 
end
ModuleScript
local items = {
    {
        id = 1,
        scaleKey = "buttonScale",
        -- ..
    },
    {
        id = 2,
        scaleKey = "panelScale",
        -- ..
    },
}

return items
ModuleScript
local uiScales = {
    ["buttonScale"] = {
        scaleKey = "buttonScale",
        Scale = 0.5,
        Offset = 0,
    },
    ["panelScale"] = {
        scaleKey = "panelScale",
        Scale = 0.8,
        Offset = 0,
    },
}

return uiScales

CFrame

Script
local cFrames = require(game.ReplicatedStorage.CFrames)   -- Adjust as needed
local items = require(game.ReplicatedStorage.Items)       -- Adjust as needed

for _, item in pairs(items) do    
    local cFrameData = cFrames[item.cFrameKey] or error("CFrame not found: " .. item.cFrameKey)

    item.cFrame = CFrame.new(cFrameData.PositionX, cFrameData.PositionY, cFrameData.PositionZ) 
        * CFrame.fromEulerAngles(math.rad(cFrameData.RotationX), math.rad(cFrameData.RotationY), math.rad(cFrameData.RotationZ)) 
end
ModuleScript
local items = {
    {
        id = 1,
        cFrameKey = "objectPosition1",
        -- ..
    },
    {
        id = 2,
        cFrameKey = "objectPosition2",
        -- ..
    },
}

return items
ModuleScript
local cFrames = {
    ["objectPosition1"] = {
        cFrameKey = "objectPosition1",
        PositionX = 0,
        PositionY = 5,
        PositionZ = 0,
        RotationX = 45, -- In degrees
        RotationY = 0,
        RotationZ = 0,
    },
    ["objectPosition2"] = {
        cFrameKey = "objectPosition2",
        PositionX = 10,
        PositionY = 8,
        PositionZ = 5,
        RotationX = 0,
        RotationY = 0,
        RotationZ = 90, -- In degrees
    },
}

return cFrames