Hello, I’m trying to make a dialogue system where it loads the possible answers depending on the number of the answer, so the first one goes first, second after, etc…
I thought it would automatically sort it out depending how the table is built, but i guess not.
Script:
function module.dialogue(Player: Player, DataTable, NPC)
--[[ DataTable Example:
{["Text: text"] = {Number: number, AttributeAction: string}}
]]
if Player.PlayerGui:FindFirstChild("DialogueUI") then return end
local Clone = script.DialogueUI:Clone()
Clone.Parent = Player.PlayerGui
Clone.Adornee = Player.Character.PrimaryPart
for i,v in pairs(DataTable) do
local Text = i
local Number = v[1]
local Action = v[2]
local Clone_upvar = script.Frame:Clone()
Clone_upvar.LayoutOrder = Number
Clone_upvar.Number.Text = "#" .. Number
Clone_upvar.Text.Text = Text
Clone_upvar.Parent = Clone.Frame
Clone_upvar:SetAttribute("ActionString", Action)
Clone_upvar:SetAttribute("NPCName", NPC.Name)
task.spawn(function()
TweenService:Create(Clone_upvar, TweenInfo.new(.5), {BackgroundTransparency = 0}):Play()
TweenService:Create(Clone_upvar.Number, TweenInfo.new(.5), {TextTransparency = 0}):Play()
TweenService:Create(Clone_upvar.Number.UIStroke, TweenInfo.new(.5), {Transparency = 0.5}):Play()
TweenService:Create(Clone_upvar.Text, TweenInfo.new(.5), {TextTransparency = 0}):Play()
TweenService:Create(Clone_upvar.Text.UIStroke, TweenInfo.new(.5), {Transparency = 0.5}):Play()
end)
task.wait(.25)
end
end