I’m working on an interaction module and feel as if I’ve created something rather long-winded. I feel as if the tree I’ve created is far too linear?
If anyone has suggestions, or even a better way of doing this I am open to ALL suggestions! Thank you.
local System = {}
local Debounce = false
function System.Configure(Player, UI, Obj)
if Debounce == false then else return end
Debounce = true
System = {Player = Player, UI = UI, Obj = Obj}
local Humanoid = Player.Character:WaitForChild("Humanoid")
Humanoid.WalkSpeed, Humanoid.JumpPower = 0, 0
UI.Dialog.Visible = true
UI.Confirm.Label.Visible = false
Default()
end
local Dialog
function Text()
for i = 1, #Dialog do
System.UI.Dialog.DialogText.Text = string.sub(Dialog, 1, i)
wait(0.05)
end
end
function Default()
System.UI.Dialog.DialogName.Text = System.Obj.Parent.Name
Dialog = "Welcome, " .. System.Player.Name .. "!"
Text()
wait(1)
Options_Set1()
end
function Options_Set1()
local DialogOptions =
{"Where am I?", "Who are you?", "Good-Bye!"}
Dialog = "How can I be of assistance today?"
Text()
wait(1)
for _,Existing in pairs (System.UI.Options:GetChildren()) do
if Existing:IsA("TextButton") then
if Existing.Name == "Template" then
else Existing:Destroy() end
end end
for _,O in pairs (DialogOptions) do
local TextButton = System.UI.Options.Template:Clone()
TextButton.Parent = System.UI.Options
TextButton.Visible = true
TextButton.Text = O
TextButton.Name = "Option"
TextButton.MouseButton1Down:Connect(function()
if TextButton.Text == DialogOptions[1] then Option_1()
elseif TextButton.Text == DialogOptions[2] then
elseif TextButton.Text == DialogOptions[3] then
end
end)
end
end
function Option_1()
for _,Existing in pairs (System.UI.Options:GetChildren()) do
if Existing:IsA("TextButton") then
if Existing.Name == "Template" then
else Existing:Destroy() end
end end
Dialog = "You're currently in 'The Hub' - This is a core location for members of AtroLyt."
Text()
wait(1)
Options_Set1()
end
return System