Text Dialog on Part

The title may sound very confusing so I’ll sum it up here.

I want to create a dialog popup whenever the player touches a part. That may sound simple in turn, just change the text based on the part’s properties and such but…

I’m currently attempting to use @Defaultio’s Rich Text Module: https://www.roblox.com/library/1014847041/Rich-Text-Markup

I’m pretty sure how it works is by getting a table of text sequences then playing it using the module.
I’m able to get it to work perfectly, the only problem is that I have no clue how I would be able to get a text sequence from a part to the local script that plays the text and pops up the dialog message.

repeat wait() until game.Players.LocalPlayer

local TextModule = require(game.ReplicatedStorage.RichTextModule)
local TS = game:GetService("TweenService")
local DF = script.Parent.DialogFrame
local TF = DF.Dialog
local CV = DF.CubeView

local Char = game.Players.LocalPlayer.Character
local Hum = Char:WaitForChild("Humanoid")
local DEB = false

local DFTweenIn = TS:Create(DF, TweenInfo.new(0.4), {Size = DF.Size, ImageTransparency = 0})
local DFTweenOut = TS:Create(DF, TweenInfo.new(0.4), {Size = DF.Size, ImageTransparency = 1})
local CVTweenIn = TS:Create(CV, TweenInfo.new(0.4), {Size = CV.Size, ImageTransparency = 0})
local CVTweenOut = TS:Create(CV, TweenInfo.new(0.4), {Size = CV.Size, ImageTransparency = 1})

local TextBeginningSeq = {
	{Text = "Hello there! Welcome to the <AnimateStyle=Wiggle><Color=Red>Simple Cubes!<Color=/>!<AnimateYield=1>", DelayTime = 2},
	{Text = "In this adventure, your journey will be <AnimateStyle=Wiggle><Color=Red>grueling and difficult!<Color=/>!<AnimateYield=1>", DelayTime = 3},
	{Text = "If you're ready to begin, get hopping!", DelayTime = 2},
}

local function ShowDialog(Text, DT)
	local TextObj = TextModule:New(TF, Text, {Font = "SourceSansLight"})
	TextObj:Animate(true)
	wait(DT)
	TextObj:Hide()
end
local function ShowFrame()
	DF.Size = UDim2.new(0.4, 0, 0.2, 0)
	DF.ImageTransparency = 1
	DF.Visible = true
	DFTweenIn:Play()
	CVTweenIn:Play()
	wait(DFTweenIn.TweenInfo.Time)
end
local function HideFrame()
	DFTweenOut:Play()
	CVTweenOut:Play()
	wait(DFTweenOut.TweenInfo.Time)
	DF.Visible = false
end
local function TouchedDialogBox()
	
end

wait(2)
ShowFrame()
for _,v in pairs(TextBeginningSeq) do
	ShowDialog(v.Text, v.DelayTime)
end
HideFrame()

The code I’m using to do pop up the dialog.

Your question is oddly phrased. Could you rephrase what you’re trying to accomplish? If you want to call functions between two scripts, you can use a BindableFunction.

What I meant was how do I get a table from one part, then transfer that table to the main script, then play that table’s text to the player.

How are you storing the table in the part?

I was thinking about just inserting a normal script into the part itself and having the table in the script.

Why not store that in the main script? If you really want to store the table, you could use a ModuleScript inside the part and do

local texts = require(workspace.Part.Texts)

When you have the texts stored somewhere in the Script and you’re ready to display, you can fire a RemoteEvent to the user with the texts and display the GUIs.

1 Like

Having 20 Tables in the main script wouldn’t be so Ideal for me :sweat:

Didn’t think about the module script, it works perfectly now, thanks!

1 Like