Simple Dialog Module

Wanting to make a game that uses dialogs?
With this module it makes dialogs simple!

Features

  1. Dialog Character Image.
  2. Three Dialog Choices

Example use:

server script:

--// Services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--// Vars
local Dialog = ReplicatedStorage:WaitForChild("Dialog")

local TutorialDialog = {
	Settings = {
		Dialog = "Would you like to start the tutorial?",
		Image = "rbxassetid://5205790785",
	},
	Options = {
		[1] = "Yes",
		[2] = "No",
	}
}

Players.PlayerAdded:Connect(function(Player)
	task.wait(5)
	
	local WantsToDoTutorial = Dialog:InvokeClient(Player, TutorialDialog.Settings, TutorialDialog.Options)
	
	repeat task.wait() until WantsToDoTutorial ~= nil
	
	print("Wants To Do Tutorial: "..tostring(WantsToDoTutorial))
end)

local script:

--// Services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--// Modules
local DialogFunc = ReplicatedStorage:WaitForChild("Dialog")

local Module = require(script:WaitForChild("Module"))

Module.Initialize()

--// Vars
local DialogEvent = ReplicatedStorage:WaitForChild("Dialog")
local Option = Module.OptionValue

function createDialog(Settings, Options)
	Module.updateDialog(Settings, Options)
	
	Option:GetPropertyChangedSignal("Value"):Wait()
	
	Module.CloseDialog()
	
	return Option.Value
end

--// Connections
DialogEvent.OnClientInvoke = createDialog

Click here for a video example.

Get the module here!

Credit for the UI: Bylocks

2 Likes

This is a neat little module, but I feel like its probably not best practice to repeat task.wait() for a boolean result, instead it would probably be better to use a signal that you can connect to.

I updated it.

It creates a string value in the module and the local script uses property change signal to wait for the value.

I don’t know if this is what you meant by that but it doesn’t use repeat task.wait() on the local script, I don’t know how I’d go about doing that for the server side script though.

1 Like