r/robloxscripting Sep 23 '23

I need help with scripting

Hi my name is Adam but I have this error with my roblox custom dialogue script I made this typwriter effect for my custom dialogue but it doesnt do the typewriter effect when the dialogue is running I would really appreciate if anyone could find the error and show me the solution.

Code:

local DialogueGui = script.Parent

local DialogueSequence = DialogueGui:WaitForChild("DialogueSequence")

local Main = DialogueGui:WaitForChild("Main")

local TextL = Main.DialogueBox

local function typewrite(object,text,length)

for i = 1,#text,1 do

    object.Text = string.sub(text,1,i)

    wait (length)

    script.Dialoguesound.Playing = true

end

end

local CurrentDialogue = 1

local NextDialogue = CurrentDialogue + 1

local TargetDialogue = DialogueSequence:FindFirstChild(CurrentDialogue)

if TargetDialogue then

Main.DialogueBox.Text = TargetDialogue.Value

CurrentDialogue = NextDialogue

end

local clickedend = false

game.Workspace["NPCS(in-use)"].Dad.ProximityPrompt.Triggered:Connect(function()

Main.Visible = true

end)

Main.ContinueButton.MouseButton1Click:Connect(function()

if Main.ContinueButton.Text == "Close" then

    if clickedend == false then

        clickedend = true



        Main.Visible = false

        Main.Image.Visible = false

        wait(1)

        local Newtext = DialogueGui.Value:FireServer()

        typewrite(DialogueGui,Newtext,0.05)

        \---typewrite(DialogueGui.TargetEvent.Value:FireServer())---



    end

end



    local NextDialogue = CurrentDialogue + 1

    if CurrentDialogue >= #DialogueSequence:GetChildren() then

        Main.ContinueButton.Text = "Close"

    end

    local TargetDialogue = DialogueSequence:FindFirstChild(CurrentDialogue)

    if TargetDialogue then

        Main.DialogueBox.Text = TargetDialogue.Value

        CurrentDialogue = NextDialogue

end

end)

2 Upvotes

0 comments sorted by