-
What do you want to achieve? A text about a quest appearing on a gui
-
What is the issue? The Typewrite function is VERY slow for some reason
The script (local):
local screengui = script.Parent
local dialogGui = screengui.Dialog
local questcenter = game.ReplicatedStorage.QuestCenter
local player = game.Players.LocalPlayer
local writing = false
local nextChild = nil
function typewrite(object, text)
writing = true
for i = 1,#text do
object.Text = string.sub(text,1,i)
print("Writing")
wait(0.05)
end
writing = false
end
function findQuest(name)
for i, v in pairs(questcenter.Quests:GetChildren()) do
if v.Name == name then
return v
end
end
end
function startQuest(quest)
player.QuestVariables.PlayerBusyWithQuest.Value = true
local folder = findQuest(quest.Parent.Name)
local dialog = folder.Dialog
dialogGui.Visible = true
nextChild = dialog:GetChildren()
while wait() do
for i, v in pairs(nextChild) do
if v.Name == "Text" then
if not writing then
nextChild = v:GetChildren()
typewrite(dialogGui, v.Value)
end
elseif v.Name == "Option1" then
for i, option in pairs(nextChild) do
local opt = Instance.new("TextButton", dialogGui.Options)
opt.Name = option.Name
opt.TextScaled = true
opt.Text = option.Value
end
end
end
end
end
while wait() do
for i, quest in pairs(questcenter:GetDescendants()) do
if quest:IsA("RemoteEvent") then
quest.OnClientEvent:Connect(function(questName)
if quest.Name == "StartQuest" then
startQuest(quest)
elseif quest.Name == "DenyQuest" then
print("Deny")
end
end)
end
end
end
Thanks for reading and hopefully you can help me.