Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how can i make a dialog system?

Asked by
omorizz 50
2 years ago

i've been working on a dialog system for weeks now and i can't find any tutorials that are working for me! i don't really know scripting so i'd like some help with making a dialog system! E proximity prompt for npcs, or just stepping on a part to make dialog appear would work!

1 answer

Log in to vote
1
Answered by 2 years ago
Edited 2 years ago

I personally use this.

First, Insert a RemotEvent named 'DIalogue' in the ReplicatedStorage.

Second, make a part and insert a ProximityPrompt. After, insert a regular Script into the Proximity Prompt, then write this.

Server

local RS = game:GetService("ReplicatedStorage")
local DialogueEvent = RS:WaitForChild("Dialogue")

local Prox = script.Parent

Prox.Triggered:Connect(function(plr)
    DialogueEvent:FireClient(plr, "Hey there! This is a dialogue system! As you can see, the breakers work! It's used as a pause in a sentence.") -- You can use this if you want, useful if you're making multiple dialogues.
end)

This will be used to send a signal to the Client that triggered the Proximity Prompt to execute the dialogue.

After doing these, make a GUI! Make your own design, put a localscript in the TextLabel (Dialogue Text). Then write this.

Client

local RS = game:GetService("ReplicatedStorage")
local Dialogue = RS:WaitForChild("Dialogue")

local Waits = {
    "!",
    ".",
    "?",
    ";",
    ":",
    ","
}

local TextLabel = script.Parent

function setText(Text)

    for i = 1, #Text do
        TextLabel.Text = string.sub(Text, 1, i)

        for Index, Breakers in pairs(Waits) do
            if string.sub(TextLabel.Text, i, i) == Breakers then
                task.wait(0.2)
            end
        end
        task.wait(0.0050) -- Customize this if you want
    end

end

Dialogue.OnClientEvent:Connect(function(msg)
    TextLabel.Parent.Parent.Enabled = true
    setText(msg)
end)

And that's a wrap! Test it out!

0
the proximity works fine, but it doesn't show the gui after proximity has loaded, not sure why? theres no output errors omorizz 50 — 2y
0
Make sure you put the Gui enabled value to true, and make sure to put the other frame's visible value into true as well in the script. If problem persist, can you send a pic of the Dialogue Gui? As well as the client-sided script. And try to put a print statement inside of theOnClientEvent, to make sure it is firing and receiving the signal. NotThatFamouss 605 — 2y
0
i fixed it by redoing the gui system, thank you for your help! but one question, how can i make multiple dialogs/sentences happen? once one finishes the next starts omorizz 50 — 2y
0
You can call the function again, with a different way. On this one, you don't have to put the string on the FireClient. It is up to you, though; but use a table. Or you can just put a table inside the Client script, then call the function. e.g: setText(Table[1]) setText(Table[2]) Make sure the table is a string, otherwise you can convert it into a string by tostring() NotThatFamouss 605 — 2y
0
If you want, you can set a speed. Formula: #Text * Sec/Letter (In this case: 0.0050). Then do a task.wait with the number. NotThatFamouss 605 — 2y
Ad

Answer this question