### Complete Bundle Configuration Example Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/resources/feature-packages/bundles.md A full example of a bundle definition including pricing, included items, and metadata. ```lua local starterBundle: Types.RelativeTimeBundle = { bundleType = Types.BundleType.RelativeTime, -- If you want to use a dev product, you must provide a unique devProductId, only used by one bundle. -- We will fetch bundle price and icon from the developer product pricing = { priceType = CurrencyTypes.PriceType.Marketplace, devProductId = , }, -- Otherwise, if you want to use in-experience currency instead of a dev product, you can use the following instead: -- Price here is in the in-experience currency, not Robux -- pricing = { -- priceType = CurrencyTypes.PriceType.InExperience, -- price = 79, -- currencyId = , -- icon = , -- }, includedItems = { [1] = { -- The item itself is not sold via a developer product, so indicate how much it is worth in Robux and give an icon -- The priceInRobux helps Bundles show relative value of the bundle price vs. the sum of its contents itemType = ItemTypes.ItemType.Robux, priceInRobux = 49, icon = , -- Alternatively, if this has a dev product leave off price and icon above and just set the devProductId -- The price and icon will be fetched from the developer product -- devProductId = -- There are more optional metadata fields that are UI-specific if needed metadata = { caption = { text = "x1", color = Color3.fromRGB(236, 201, 74), }, }, }, [2] = { itemType = ItemTypes.ItemType.Robux, priceInRobux = 99, icon = , metadata = { caption = { text = "x1", color = Color3.fromRGB(236, 201, 74), }, }, }, [3] = { itemType = ItemTypes.ItemType.Robux, priceInRobux = 149, icon = , metadata = { caption = { text = "x1", color = Color3.fromRGB(236, 201, 74), }, }, }, }, singleUse = true, -- Once purchased or expired, no longer valid even if your experience tries to prompt (onPlayerAdded). You can make this false while testing in studio. durationInSeconds = 900, -- 15 minutes includesOfflineTime = false, -- Only count time elapsed in the experience metadata = { displayName = "STARTER BUNDLE", description = "Save 75% and get a head start!", }, } ``` -------------------------------- ### Example Output Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/luau/stacks.md This is the expected output when running the Stack Usage Example code. ```lua 10 5 20 1 ``` -------------------------------- ### Install Dependencies Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/cloud/auth/oauth2-sample.md Install the necessary project dependencies using npm. Ensure you have Node.js and npm installed. ```bash npm ci ``` -------------------------------- ### Initializing Services and Variables Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/tutorials/curriculums/core/scripting/script-game-behavior.md Initial setup for service references and coin collection variables. ```lua local Workspace = game:GetService("Workspace") local Players = game:GetService("Players") local coinsFolder = Workspace.World.Coins local coins = coinsFolder:GetChildren() local COOLDOWN = 10 ... ``` -------------------------------- ### Get Directions for Blast (Vertical Spread Example) Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/tutorials/curriculums/gameplay-scripting/detect-hits.md An example demonstrating how to calculate laser directions for a vertical spread. This is a hypothetical scenario for a third blaster type. ```lua if numLasers == 1 then table.insert(directions, originCFrame.LookVector) elseif numLasers > 1 then local leftAngleBound = laserSpreadDegrees / 2 local rightAngleBound = -leftAngleBound local degreeInterval = laserSpreadDegrees / (numLasers - 1) for angle = rightAngleBound, leftAngleBound, degreeInterval do local direction if spreadDirection == "vertical" then direction = (originCFrame * CFrame.Angles(math.rad(angle), 0, 0)).LookVector else direction = (originCFrame * CFrame.Angles(0, math.rad(angle), 0)).LookVector end table.insert(directions, direction) end end return directions ``` -------------------------------- ### Configure Rojo Project for Package Installation Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/projects/external-tools.md Add the 'Packages' directory to your Rojo project configuration to sync installed Wally packages into Roblox Studio. This example places them in ReplicatedStorage for broad accessibility. ```json { "name": "my-new-experience", "tree": { "$className": "DataModel", "ReplicatedStorage": { "Shared": { "$path": "src/shared" }, "Packages": { "$path": "Packages" } }, ... } } ``` -------------------------------- ### Lua For Loop - Basic Example Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/tutorials/fundamentals/coding-4/intro-to-for-loops.md A standard for loop that starts at 0, prints the count in each iteration, increments the count by 1, and stops when the count reaches 10. ```lua for count = 0, 10, 1 do print(count) end ``` -------------------------------- ### Run the Application Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/cloud/auth/oauth2-sample.md Start the Node.js OAuth 2.0 sample application. After running, access it via your web browser. ```bash npm start ``` -------------------------------- ### Require and Use Wally Packages in Lua Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/projects/external-tools.md Demonstrates how to use `require` to import modules installed via Wally. This example sets up a basic React UI with a TextLabel. ```lua local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local React = require(ReplicatedStorage.Packages.react) local ReactRoblox = require(ReplicatedStorage.Packages["react-roblox"]) local handle = Instance.new("ScreenGui", Players.LocalPlayer.PlayerGui) local root = ReactRoblox.createRoot(handle) local helloFrame = React.createElement("TextLabel", { Text = "Hello World!", Size = UDim2.new(0, 200, 0, 200), Position = UDim2.new(0.5, 0, 0.5, 0), AnchorPoint = Vector2.new(0.5, 0.5), BackgroundColor3 = Color3.fromRGB(248, 217, 109), Font = Enum.Font.LuckiestGuy, TextSize = 24 }) root:render(helloFrame) ``` -------------------------------- ### Initialize ContextActionService Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/tutorials/use-case-tutorials/input-and-camera/detect-user-input.md Setup the service and define the action name constant at the top of the script. ```lua local ContextActionService = game:GetService("ContextActionService") local tool = script.Parent local RELOAD_ACTION = "reloadWeapon" ``` -------------------------------- ### Get Players Service and Local Player Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/tutorials/use-case-tutorials/input-and-camera/control-the-users-camera.md This snippet retrieves the Players service and the local player object. It's a common setup for client-side scripts that need to interact with player-specific data. ```lua local Players = game:GetService("Players") local player = Players.LocalPlayer ``` -------------------------------- ### Open a place via command line Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/studio/command-line-interface.md Use these commands to launch Studio and open a specific place or a specific version of a place. ```shell Roblox.exe -placeId 101570895440344 -universeId 9808504031 -task EditPlace ``` ```shell Roblox.exe -placeId 101570895440344 -universeId 9808504031 -task EditPlaceRevision -placeVersion 2 ``` -------------------------------- ### Initialize and Build a Rojo Project Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/projects/external-tools.md Generate the project structure for a new experience and build the initial project file. This sets up a new project for Rojo synchronization. ```bash rojo init my-new-experience cd my-new-experience rojo build -o my-new-experience.rbxl ``` -------------------------------- ### Get Player Tool Handle on Server Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/tutorials/use-case-tutorials/scripting/intermediate-scripting/hit-detection-with-lasers.md Finds the handle of the tool the player is currently holding. This is used to determine the starting position of the laser beam. It returns the handle object if found, otherwise nil. ```lua local LASER_DAMAGE = 10 -- Find the handle of the tool the player is holding local function getPlayerToolHandle(player) local weapon = player.Character:FindFirstChildOfClass("Tool") if weapon then return weapon:FindFirstChild("Handle") end end ``` -------------------------------- ### Execute bundle command Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/education/support/creating-bundled-installers.md Run the launcher executable with the -bundle flag in the Command Prompt to generate a bundled installer. ```bash RobloxStudioLauncherBeta.exe -bundle RobloxPlayerLauncher.exe -bundle ``` -------------------------------- ### Example Material Plugin with Recordings for Undo and Redo Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/studio/plugins.md This plugin applies the neon material to selected parts and uses ChangeHistoryService to enable undo and redo functionality for these changes. Ensure no other recordings are active before starting a new one. ```lua local ChangeHistoryService = game:GetService("ChangeHistoryService") local Selection = game:GetService("Selection") -- Create an example plugin local toolbar = plugin:CreateToolbar("Example Plugin") local button = toolbar:CreateButton("Neon it up", "", "") -- Connect a function to the click event button.Click:Connect(function() -- Try to begin a recording with a specific identifier local recording = ChangeHistoryService:TryBeginRecording("Set selection to neon") -- Check if recording was successfully initiated if not recording then -- This indicates that your plugin began a previous recording and never completed it -- You may only have one recording per plugin active at a time return end -- Iterate through the selected instances for _, instance in Selection:Get() do -- Check if the instance is a BasePart if instance:IsA("BasePart") then instance.Material = Enum.Material.Neon -- Set the material of the part to Neon end end -- Finish the recording, committing the changes to the history ChangeHistoryService:FinishRecording(recording, Enum.FinishRecordingOperation.Commit) end) ``` -------------------------------- ### Authenticate Open Cloud API Requests Source: https://context7.com/roblox/creator-docs/llms.txt Use API keys generated from the Creator Dashboard to authenticate requests to the Open Cloud API. This example shows how to include the key in headers for GET requests and how to introspect a key. ```bash # Create API key at: https://create.roblox.com/dashboard/credentials # Include key in request header curl -X GET "https://apis.roblox.com/cloud/v2/users/12345" \ -H "x-api-key: YOUR_API_KEY_HERE" # Introspect an API key to check permissions curl -X POST "https://apis.roblox.com/api-keys/v1/introspect" \ -H "Content-Type: application/json" \ -d '{"apiKey": "YOUR_API_KEY_HERE"}' # Response shows scopes and permissions: # { ``` -------------------------------- ### Initialize SellPlatform reference Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/education/adventure-game-series/selling-items.md Defines the platform part within the script's parent. ```lua -- Sells all a player's items and gives them gold local sellPart = script.Parent ``` -------------------------------- ### Handle In-Game Purchase Click Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/production/monetization/developer-products.md Combine `GetProductInfo` and `PromptProductPurchase` within a `LocalScript` to create interactive purchase elements. This example shows how to get product details, check if it's for sale, and prompt a purchase when a UI button is clicked. ```lua local MarketplaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players") local player = Players.LocalPlayer local button = script.Parent -- Replace the placeholder ID with your developer product ID local productId = 000000 -- Gets product info when user clicks the UI button button.MouseButton1Click:Connect(function() local success, productInfo = pcall(function() return MarketplaceService:GetProductInfo(productId, Enum.InfoType.Product) end) if success and productInfo then -- Checks if product is for sale if productInfo.IsForSale then print("This is for sale") -- Prompts product purchase MarketplaceService:PromptProductPurchase(player, productId) else -- Notifies product isn't for sale print("This product is not currently for sale.") end else print("Error retrieving product info: " .. tostring(productInfo)) end end) ``` -------------------------------- ### Directing to Authorization Flow Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/cloud/auth/oauth2-reference.md Example URL for initiating the user authorization flow with required query parameters. ```plain https://apis.roblox.com/oauth/v1/authorize?client_id=816547628409595165403873012&redirect_uri=https://my-app.com/redirect&scope=openid&response_type=code&nonce=12345&state=6789 ``` -------------------------------- ### Example PKCE Authorization URL Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/cloud/auth/oauth2-develop.md Construct this URL to initiate the user authorization process using PKCE. Ensure all required parameters like client_id, code_challenge, and redirect_uri are correctly formatted. ```bash https://apis.roblox.com/oauth/v1/authorize?client_id=7290610391231237934964 &code_challenge=PLEKKVCjdD1V_07wOKlAm7P02NC-LZ_1hQfdu5XSXEI &code_challenge_method=S256 &redirect_uri=https://example.com/redirect &scope=openid%20profile &response_type=code &state=abc123 ``` -------------------------------- ### Start the Timer Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/education/battle-royale-series/timers-and-events.md Trigger the timer start method and connect the completion event. ```lua -- Local Functions local function startTimer() print("Timer started") myTimer:start(gameSettings.matchDuration) myTimer.finished:Connect(timeUp) end ``` -------------------------------- ### Serve a Rojo Project Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/projects/external-tools.md Start the Rojo server to enable synchronization between local files and Roblox Studio. This command should be run in the project directory. ```bash rojo serve ``` -------------------------------- ### Example Description Field Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/cloud/webhooks/automate-right-to-erasure.md An example of a formatted description field for a Right to Erasure webhook notification. ```plain 1683927229. You have received a new notification for Right to Erasure for the User Id: 2425654247 in the game(s) with Ids: 10539205763, 13260950955 ``` -------------------------------- ### Initialize Buy Button and Click Detector Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/education/adventure-game-series/buying-upgrades.md Sets up variables to reference the parent part and its ClickDetector. This is the initial setup for a clickable shop button. ```lua -- Lets players click a button to buy an upgrade that increases Spaces local buyButton = script.Parent local clickDetector = buyButton.ClickDetector ``` -------------------------------- ### Iteration Algorithm Example Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/tutorials/fundamentals/coding-6/coding-concept-algorithms.md Repeats parts of the code as necessary, such as in for loops or multiplication. This example counts down from 10. ```lua for countDown = 10, 1, -1 do time -= 1 task.wait(1) end ``` -------------------------------- ### Tutorial Manager Script Implementation Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/education/build-it-play-it-mansion-of-wonder/adding-scripts.md This script manages tutorial goals, updates visual beams between the player and targets, and handles proximity prompt interactions. ```lua local tutorialFolder = ReplicatedStorage:WaitForChild("PlayerTutorial") local TutorialManager = require(tutorialFolder:WaitForChild("TutorialManager")) local TutorialEndEvent = tutorialFolder:WaitForChild("TutorialEnd") local player = Players.LocalPlayer local goalParts = TutorialManager.getTutorialGoals() local playerBeam = nil local goalIndex = nil local function getTargetAttachment() local currentTarget = goalParts[goalIndex.Value] local interactionPart = currentTarget:FindFirstChild("InteractionPart") local attachment = interactionPart and interactionPart:FindFirstChildOfClass("Attachment") if not attachment then attachment = Instance.new("Attachment") attachment.Name = "BeamAttachment" attachment.Parent = currentTarget end return attachment end local function updateBeamTarget() playerBeam = player.Character.HumanoidRootPart:FindFirstChildOfClass("Beam") local targetBeamAttachment = getTargetAttachment() if targetBeamAttachment then playerBeam.Attachment1 = targetBeamAttachment else warn("Attachment not found in a goal. Check that goals have attachments or they're included under the InteractionPart") end end local function setupGoals() for _, part in goalParts do local interactionPart = part:FindFirstChild("InteractionPart") local proximityPrompt = interactionPart and interactionPart:FindFirstChild("ProximityPrompt") if proximityPrompt then proximityPrompt.Triggered:Connect(function(player) proximityPrompt.Enabled = false TutorialManager.nextGoal(player, goalParts) TutorialManager.interactGoal(player) end) else warn("Proximity prompt not included in goal. Add one to each goal part under the InteractionPart") end end end local function createBeamForCharacter(character) local humanoidRootPart = character:WaitForChild("HumanoidRootPart") local playerBeamAttachment = Instance.new("Attachment") local beamTemplate = tutorialFolder:WaitForChild("TutorialBeam") if not beamTemplate then warn("Tutorial Beam not found in ReplicatedStorage") end playerBeamAttachment.Name = "BeamAttachment" playerBeamAttachment.Parent = humanoidRootPart local targetBeamAttachment = getTargetAttachment() playerBeam = beamTemplate:Clone() playerBeam.Attachment0 = playerBeamAttachment playerBeam.Attachment1 = targetBeamAttachment playerBeam.Enabled = true playerBeam.Parent = humanoidRootPart end local function setupPlayer() setupGoals() TutorialManager.setupPlayerProgress(player) goalIndex = player:WaitForChild("GoalProgress") player.CharacterAdded:Connect(createBeamForCharacter) if player.Character then createBeamForCharacter(player.Character) end end setupPlayer() goalIndex.Changed:Connect(updateBeamTarget) ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/cloud/webhooks/automate-right-to-erasure.md Required libraries for the bot automation logic. Ensure these are installed in your environment before running the scripts. ```bash pip3 install discord pip3 install requests pip3 install urllib3==1.26.6 ``` -------------------------------- ### Create ScreenGui and StyleLink Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/ui/styling/editor.md This process involves inserting a ScreenGui into StarterGui and ensuring a StyleLink instance is created and linked to a design sheet. If the StyleLink is not automatically created, it can be manually inserted. ```Lua 1. Hover over `Class.StarterGui` in the [Explorer](../../studio/explorer.md) and insert a `Class.ScreenGui`. 2. Confirm that a new `Class.StyleLink` instance appears under the `Class.ScreenGui` with its `Class.StyleLink.StyleSheet|StyleSheet` property set to the **StyleSheet** design sheet. ``` -------------------------------- ### Initialize DataStoreService and GetDataStore Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/tutorials/use-case-tutorials/data-storage/save-player-data.md Initialize the DataStoreService and call GetDataStore with a unique name for your data store. This code should be placed in a server-side Script. ```lua local DataStoreService = game:GetService("DataStoreService") local goldStore = DataStoreService:GetDataStore("PlayerGold") ``` -------------------------------- ### Example JSON Response Body Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/cloud/webhooks/automate-right-to-erasure.md This is an example of the JSON payload that might be received for a RightToErasureRequest, including signature and timestamp details. ```json { "embeds": [ { "title": "RightToErasureRequest", "description": "You have received a new notification for Right to Erasure for the User Id: 2425654247 in the game(s) with Ids: 10539205763, 13260950955", "footer": { "icon_url": "https://create.roblox.com/dashboard/assets/webhooks/roblox_logo_metal.png", "text": "Roblox-Signature: UIe6GJ78MHCmU/zUKBYP3LV0lAqwWRFR6UEfPt1xBFw=, Timestamp: 1683927229" } } ] } ``` -------------------------------- ### Initialize DisplayManager Module Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/education/battle-royale-series/creating-a-gui.md Sets up the base structure for the DisplayManager module script with necessary service and folder references. ```lua local DisplayManager = {} -- Services local ReplicatedStorage = game:GetService("ReplicatedStorage") -- Display Values used to update Player GUI local displayValues = ReplicatedStorage:WaitForChild("DisplayValues") local status = displayValues:WaitForChild("Status") -- Local Functions -- Module Functions return DisplayManager ``` -------------------------------- ### Connect Match Start Event Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/education/battle-royale-series/timers-and-events.md Connects the 'MatchStart' event to the 'startTimer' function. This ensures the timer begins when the match officially starts. ```lua -- Module Functions function MatchManager.prepareGame() playerManager.sendPlayersToMatch() end matchStart.Event:Connect(startTimer) return MatchManager ``` -------------------------------- ### Initialize Player Attributes Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/tutorials/use-case-tutorials/scripting/basic-scripting/score-points.md Sets up leaderstats and an initial IsAlive attribute for a player when they join. ```lua local function onPlayerAdded(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local points = Instance.new("IntValue") points.Name = "Points" points.Value = 0 points.Parent = leaderstats player:SetAttribute("IsAlive", false) player.CharacterAdded:Connect(function(character) onCharacterAdded(character, player) end) end ``` -------------------------------- ### Get an Instance Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/cloud/guides/instance.md Retrieves a single Roblox Instance. The response includes an Operation object that you poll to get the actual instance data. ```APIDOC ## GET /cloud/v2/universes/{universeId}/places/{placeId}/instances/{instanceId} ### Description This method returns a single [Instance](/cloud/reference/Instance). ### Method GET ### Endpoint https://apis.roblox.com/cloud/v2/universes/{universeId}/places/{placeId}/instances/{instanceId} ### Parameters #### Path Parameters - **universeId** (string) - Required - The ID of the universe. - **placeId** (string) - Required - The ID of the place. - **instanceId** (string) - Required - The ID of the instance. ### Request Example ```python import requests apiKey = "" universeId = "" placeId = "" instanceId = "" apiKeyHeaderKey = "x-api-key" getInstanceUrl = "https://apis.roblox.com/cloud/v2/universes/%s/places/%s/instances/%s" def GetInstance(): url = getInstanceUrl % (universeId, placeId, instanceId) headerData = {apiKeyHeaderKey: apiKey} return requests.get(url, headers = headerData) response = GetInstance() print("Response:", response.status_code, response.text) operationPath = response.json()['path'] ``` ```bash curl --include --location --request GET "https://apis.roblox.com/cloud/v2/universes//places//instances/" --header "x-api-key: " ``` ### Response #### Success Response (200) - **path** (string) - The path to poll for operation results. - **done** (boolean) - Indicates if the operation is complete. - **response** (object) - The result of the operation, containing instance details. #### Response Example ```json { "path": "universes/1234567890/places/98765432109/instances/root/operations/a1a2a3a4-a1a2-a1a2-a1a2-a1a2a3a4a5a6", "done": true, "response": { "@type": "type.googleapis.com/roblox.open_cloud.cloud.v2.ListInstanceChildrenResponse", "instances": [ { "path": "universes/1234567890/places/98765432109/instances/b1b2b3b4-b1b2-b1b2-b1b2-b1b2b3b4b5b6", "hasChildren": true, "engineInstance": { "Id": "b1b2b3b4-b1b2-b1b2-b1b2-b1b2b3b4b5b6", "Parent": "a1a2a3a4-a1a2-a1a2-a1a2-a1a2a3a4a5a6", "Name": "Workspace", "Details": {} } } ] } } ``` ``` -------------------------------- ### Install Rojo Plugin Source: https://github.com/roblox/creator-docs/blob/main/content/en-us/projects/external-tools.md Install the Rojo plugin for Roblox Studio using the command line. This is a prerequisite for using Rojo to sync projects. ```bash rojo plugin install ```