Dialog System not detecting a value change?

Hey guys. I’m trying to make a camera system that the player’s face will be shown, then a dialog line will change the text, character-by-character.

My Button Press Script:

script.Parent.Parent.Continue.MouseButton1Click:Connect(function()
	print("Continue")
	script.Parent.Parent.Page.Value = script.Parent.Parent.Page.Value + 1
end)

And my Text Changer script:

game:GetService("StarterGui").RecordingEvents.ShowDialog.Event:Connect(function()
	script.Parent.Parent.Enabled = true
	local dialog = math.random(1)
	--table--
	script.Parent.Parent.Value.Changed:Connect(function()
		if dialog == 1 then
			local dialog1 = "Hey guys.  I hope you enjoy watching Alone on RTV!"
			local dialog2 = "Anyways, this is difficult to win!  There's a lot of struggles I've went through."
			local dialog3 = "It's way different out here!  For example, having to boil water is much different than just drinking from the fridge..."
			local dialog4 = "The only thoughts you get out here are either thinking how many people are still in the game, or what's going on with your family."
			local dialog5 = "I really miss my family.  I've gotta go chop some trees and do some more work.  Alright, bye guys, and hi mom!"
			if script.Parent.Parent.Page.Value == 1 then
				print("1")
				for i=1,#dialog1 do
					script.Parent.TextLabel.Text = string.sub(dialog1, 1, i)
					wait(.25)
				end
			elseif script.Parent.Parent.Page.Value == 2 then
				print("2")
				for i=1,#dialog2 do
					script.Parent.TextLabel.Text = string.sub(dialog2, 1, i)
					wait(.25)
				end
			elseif script.Parent.Parent.Page.Value == 3 then
				print("3")
				for i=1,#dialog3 do
					script.Parent.TextLabel.Text = string.sub(dialog3, 1, i)
					wait(.25)
				end
			elseif script.Parent.Parent.Page.Value == 4 then
				print("4")
				for i=1,#dialog4 do
					script.Parent.TextLabel.Text = string.sub(dialog4, 1, i)
					wait(.25)
				end
			elseif script.Parent.Parent.Page.Value == 5 then
				print("5")
				for i=1,#dialog5 do
					script.Parent.TextLabel.Text = string.sub(dialog5, 1, i)
					wait(.25)
				end
			else
				script.Parent.TextLabel.Visible = false
			end
		end
	end)
end)

My text will not change, but the print("Continue") line will print.

Thanks for any help!

Did you mean script.Parent.Parent.Value.Changed or script.Parent.Parent.Page.Changed? It seems you are looking at the wrong object in your Changed connection. Side note, a lot of your code can be simplified into a for-loop.

Yes, sorry. But it still doesn’t, for some reason, function as I want it to.

Also, could you provide a 2-page example of a for loop if possible? Thanks so much!

1 Like

Firstly, I’d highly recommend condensing your code and using variables. To answer your problem, the dialog is only going to show up if script.Parent.Parent.Value changes. From the code that you posted, I don’t see anything that changes that object’s value. Keep in mind that you shouldn’t be doing IntValue.Value.Changed but rather IntValue.Changed.

Here’s how you can condense your code:

local dialogs = -- array of dialogs
-- Changed Event happened
for i, dialog in ipairs (dialogs) do
    if page.value is equal to i then
        -- type out the text
    end
end

Oh, no, this is my explorer, btw.
image

OK. I will start defining some things.

You have an error because Value is not a member of script.Parent.Parent. It’s like I said:

I changed it and it still didn’t work. And I’m not getting any errors.

Please condense your LATEST code (use variables too otherwise we’d have to scroll back and forth) and hierarchy and post it here.

if your trying to make it where it shows player, you can use viewportframes,and aim it player head,you can use math.random to show a random player

That isn’t what I want. Thanks though.

If its not giving any errors, then use the print() function to see what lines of code run and which ones don’t.

Don’t use StarterGui, use PlayerGui instead! Instead of game:GetService("StarterGui"), try game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui"), so it becomes:

game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui").RecordingEvents.ShowDialog.Event:Connect(function()`

This is very long, so you can reduce it by making variables, like so:

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
PlayerGui.RecordingEvents.ShowDialog.Event:Connect(function()
1 Like