Skip to content

ChoiceDialog

A two-step, single-choice Dialog with built-in Replication.

This library registers a Material Design ChoiceDialog PseudoInstance which can be instantiated via PseudoInstance.new("ChoiceDialog").

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Resources = require(ReplicatedStorage:WaitForChild("Resources"))
local PseudoInstance = Resources:LoadLibrary("PseudoInstance")
local ChoiceDialog = PseudoInstance.new("ChoiceDialog")

ChoiceDialog API

ChoiceDialog inherits from ReplicatedPseudoInstance

Fields

Property Type Description
PrimaryColor3 Color3 The color of the radio/ripple buttons
Options array of strings The options presented
HeaderText string The Dialog title
DismissText string The Dismiss text (the left button)
ConfirmText string The Confirm text (the right button)

Events

Event Description Signature
OnConfirmed Fires after the ChoiceDialog was Confirmed/Dismissed: if confirmed, passes in string OptionChosen (Player Player, string Choice)
ChoiceDialog also inherits from PseudoInstance

Example

Click here for the example place

Demo code:

-- This code is valid on the client and server
-- Just make sure that both call `Resources:LoadLibrary("ReplicatedPseudoInstance")`

-- If this is in a Script, it will Replicate this ChoiceDialog to every
-- Player in the game and everyone who joins
-- If this is in a LocalScript, it will generate it on the client only

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Resources = require(ReplicatedStorage:WaitForChild("Resources"))

local Color = Resources:LoadLibrary("Color")
local PseudoInstance = Resources:LoadLibrary("PseudoInstance")

Resources:LoadLibrary("ReplicatedPseudoInstance")

local PrimaryColor3 = Color.Teal[500] -- This is just a Color3 value

local Dialog = PseudoInstance.new("ChoiceDialog")
Dialog.HeaderText = "Repository Location"
Dialog.Options = {"ServerStorage", "ServerScriptService"}
Dialog.DismissText = "CANCEL"
Dialog.ConfirmText = "INSTALL"
Dialog.PrimaryColor3 = PrimaryColor3

Dialog.OnConfirmed:Connect(function(Player, Choice)
    print(Player, Choice)

    if Choice then
        -- Choice is a string of the option they chose
    else
        -- They chose Dismiss, so Choice is false
    end
end)

Dialog.Parent = ReplicatedStorage