Dialog script won't work - UI script

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to make a dialog for my guide npc wich says anything i put in the script…

  2. What is the issue? Include screenshots / videos if possible!
    So like in the textlabel i did put nothing as the text value, and i made a script that fils in the value if the ScreenGui is enabled, but it won’t change the text when i launch the game…

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I did look for solutions but nothing , iremade the script but nothing, so i need help…
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local DialogText = script.Parent

if script.Parent.Parent.Parent.Enabled == true then
wait(0.1)
DialogText.Text = "Hello, my name is Bob! Im your guide fro today (not really), have you got question?"
wait(5)
DialogText.Text = "I guess not..."
wait(3)
DialogText.Text = "In this map you can play obbies and tower defense mini-games!"
wait(4)
DialogText.Text = "This map was created for events that are held by ADB, currently the vent is for NTD!"
wait(5)
DialogText.Text = "On my left there is the Tower Defense game, on my right is the obbies with multiple themes!"
wait(5)
DialogText.Text = "Now, you can go play with friends, bye bye!"
wait(3)
script.Parent.Parent.Parent.Enabled = false
end
1 Like

Can you show me the path to this script, the path might be not correct so basically the dialogue doesnt start.

2 Likes

Why don’t you just make it chat.

local chat = game:GetService("Chat")
local npc = workspace.npc -- or something

chat:Chat(npc,"Hello, my name is Bob! Im your guide fro today (not really), have you got question?","Blue")
wait(5) 
-- repeat 
2 Likes

yes but, how do im make it lunches when the player touches a part??

1 Like
local chat = game:GetService("Chat")
local npc = workspace.npc -- Replace with NPC, or whatever
local part = workspace.Part -- Replace with your part

local function DialogueSequnce()
   chat:Chat(npc,"Hello, my name is Bob! Im your guide fro today (not really), have you got question?","Blue")
   -- Do other stuff
end

part.Touched:connect(DialogueSequnce)

This just tells when the part variable is touched, it then triggers the DialogueSequence function, which does the dialogue

2 Likes

this condition might not be true, show the path to this script.

2 Likes

okay, this won’t change much, but can you PLEASE do something like this?

local function ChangeDialogueText(textToDisplay: string)
   DialogText.Text = textToDisplay -- if DialogText is defined above the function
   -- you can just reference to it, if it's not defined, you can pass it as a parameter

end

task.wait(x)
ChangeDialogueText("Your text here")

also, i think the reason it doesn’t work is because:

this will run once when the client loads in, and since the screenGui (assuming that’s the finishing parent) is not enabled, it will ignore that check and never rerun again

a simple fix (Because i cannot be bothered to do anything bigger than that) would be to do something like this:

if not pathToScreenGui.Enabled then
   repeat task.wait() until pathToScreenGui.Enabled
end
3 Likes

That’s not going to work in a localscript.

2 Likes

Hmm yeah didnt think of that one, in that case just set DialogText.Text to the message of choice instead of what I did

2 Likes

Make a remote event inside replicated storage called NPC

Server Script In ServerScriptService:

local part = workspace.Part -- Replace part with the part that you need to fire the function

part.Touched:Connect(function(hit)
     if game.Players:GetPlayerFromCharacter(hit.Parent) then
          game.ReplicatedStorage.NPC:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent))
     end
end)

Local Script in StarterPlayerScripts:

local NPC = workspace.NPC -- Replace NPC with the NPC's Head
local chat = game:GetService("Chat")

game.ReplicatedStorage.NPC.OnClientEvent:Connect(function()
     chat:Chat(NPC,"Hello, my name is Bob! Im your guide fro today (not really), have you got a question?","Blue")
     wait(5)
     chat:Chat(NPC,"I guess not...","Blue")
     wait(3)
     chat:Chat(NPC,"In this map, you can play obbies and tower defense mini games! ","Blue")
     wait(4)
    chat:Chat(NPC,"This map was created for events that are held by ADB, currently the vent is for NTD!","Blue")
     wait(5)
    chat:Chat(NPC,"On my left there is the Tower Defense game, on my right is the obbies with multiple themes!","Blue")
     wait(5)
    chat:Chat(NPC,"Now, you can go play with friends, bye bye!","Blue")
end)

That should work.

2 Likes

Everyone! :

I added a dialog instance in the Rig, but this is not the final system, I’m gonna try all your solutions.

Thanks!

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.