Hello people from the DevForum community, so I wanted to make the dialogue table changed when a task is completed on a tutorial. Basically how it works is the script will make a table, then the script copies the value from each StringValue on a specific room from the folder and then the script will input it to the table.
But once the table has been input, the script doesn’t work. There are no errors in the script. However, I tried on serverscript with remote events as well but that also doesn’t work. How do I solve this issue or is there another simple way.
local TextLabel = script.Parent.Dialog
local dialogue = {}
local remoteevent = game:GetService("ReplicatedStorage").Dialogues.Room_1
local function typewriterEffect(object, text)
for i = 1, #text do
object.Text = string.sub(text, 1, i)
wait(0.06)
end
end
local function clearTable()
for k in pairs (dialogue) do
dialogue [k] = nil
print(dialogue)
end
end
local function Dialogue2()
for _, value in pairs(game.Workspace.Dialogs.Room2:GetChildren()) do
dialogue[value.Name] = value.Value
print(dialogue)
end
end
local function DialogRoom2()
wait(3)
typewriterEffect(TextLabel, dialogue["Dialog_1"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_2"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_3"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_4"])
end
local function DialogRoom1()
wait(3)
typewriterEffect(TextLabel, dialogue["Dialog_1"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_2"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_3"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_4"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_5"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_6"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_7"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_8"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_9"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_10"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_11"])
end
for _, value in pairs(game.Workspace.Dialogs.Room1:GetChildren()) do
dialogue[value.Name] = value.Value
print(dialogue)
end
DialogRoom1()
while wait() do
if game.Workspace.CodeInput.Code_1.Success.Material == Enum.Material.Neon then -- when task completed
Dialogue2()
print("yippee!")
wait(3)
DialogRoom2()
end
end
ServerScript Version
Script
local remoteevent = game:GetService("ReplicatedStorage").Dialogues.Room_1
local dialogue = {}
local function dialog1() -- Dialogue1
for _, value in pairs(game.Workspace.Dialogs.Room1:GetChildren()) do
dialogue[value.Name] = value.Value
print(dialogue)
end
remoteevent:FireAllClients(dialogue)
end
local function dialog2() -- THIS IS JUST AN EXAMPLE! IT WON'T RUN
for k in pairs (dialogue) do
dialogue [k] = nil
print(dialogue)
end
wait(3)
for _, value in pairs(game.Workspace.Dialogs.Room2:GetChildren()) do
dialogue[value.Name] = value.Value
print(dialogue)
end
remoteevent:FireAllClients(dialogue)
end
dialog1()
LocalScript
local TextLabel = script.Parent.Dialog
local remoteevent = game:GetService("ReplicatedStorage").Dialogues.Room_1
local function typewriterEffect(object, text)
for i = 1, #text do
object.Text = string.sub(text, 1, i)
wait(0.06)
end
end
remoteevent.OnClientEvent:Connect(function(plr, dialogue)
wait(3)
typewriterEffect(TextLabel, dialogue["Dialog_1"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_2"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_3"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_4"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_5"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_6"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_7"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_8"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_9"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_10"])
wait(4)
typewriterEffect(TextLabel, dialogue["Dialog_11"])
end)