Text changes but I can't see it (I change it from PlayerGui)

Hello DevForum!
Let’s get right into the issue. So, I’m trying to change the text whenever the count increases.

I use 3 scripts, 1 Server, 2 Local. First one is (Server Script) to increase the count when MaxVisibleGrapheme reaches 7, second one is (Local Script) to listen to count.Value changes to change the text and the last one is (Local Script) to give the text it’s TypeWriter effect so has no significant effects.

So, when I try to run it, first script works good if we don’t mind multiple prints (I tried debounce and it didn’t work) and after we come to the second script (that listens to changes) it successfully gets the signal. And that’s where the problem comes. So, it changes the text when count reaches 1. I tried to see it if it gets the signal and it gets the signal too but when it changes the text (again, I tested it with print and it changes (?)) I can’t see it on screen and yes I am changing the PlayerGui.

I tried to change StarterGui and PlayerGui to see if it works but it didn’t help.

I am trying to fix this for days, can you guys help me out please?

Here is the scripts (Scripts may be a little scrambled but I’ll fix them when I fix this):

Server Script:

local trigger = game.Workspace.Triggers.Dialogues:WaitForChild("trigger0")

debounce = false

local function onTouched(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local Character = hit.Parent
		local Player = game.Players:GetPlayerFromCharacter(Character)
		
		local dialogueText = Player.PlayerGui.Dialogues.Frame.TextLabel
		local text = dialogueText.Text
		
		local dialogueCount = Player:WaitForChild("Dialogue Count")
		local count = dialogueCount:WaitForChild("DialogueCount")
		
		dialogueText.Visible = true
		trigger.CanTouch = false
		
		local index = 0
		for first, last in utf8.graphemes(text) do 
			local grapheme = text:sub(first, last) 
			index += 1
			dialogueText.MaxVisibleGraphemes = index
			wait()
		end
		
		if dialogueText.MaxVisibleGraphemes == 7 then
			wait(5)
			dialogueText.Visible = false
			debounce = true --These debounces is for testing if cooldown works (it didn't)
			count.Value = 1
			debounce = false
			debounce = true
			print(count.Value,"count")
			debounce = false
			debounce = true
			dialogueText.MaxVisibleGraphemes = 0
			debounce = false
			debounce = true
			print(dialogueText.MaxVisibleGraphemes,"mvg")
			debounce = false
			wait()
		end
	end
end

trigger.Touched:Connect(onTouched)

Local Script/Count.Value change listener:

local dialogueBindable = game.Workspace.Bindables.Dialogue.dialogue

local lp = game.Players.LocalPlayer

local dialogueCount = lp:WaitForChild("Dialogue Count")
local count = dialogueCount:WaitForChild("DialogueCount")

count:GetPropertyChangedSignal("Value"):Connect(function()
	local plrGUI = lp:WaitForChild("PlayerGui")
	local dialogues = plrGUI:WaitForChild("Dialogues")
	local dialogueText = dialogues.Frame.TextLabel
	local text = dialogueText.Text
	
	local dialogueTextServer = game.StarterGui.Dialogues.Frame.TextLabel
	local textServer = dialogueTextServer.Text
	
	print(count.Value)
	
	if count.Value == 1 then
		text = "text1"
		textServer = "text1"
		print(text,",",textServer) --These ones is to test if PlayerGui or StarterGui does the job.
		dialogueText.Visible = true
	end
	
	if count.Value == 2 then --These one should work when I fix these.
		text = "text2"
		dialogueText.Visible = true
	end
	
	if count.Value == 3 then
		text = "text3"
		dialogueText.Visible = true
	end
	
	if count.Value == 4 then
		text = "text4"
		dialogueText.Visible = true
	end
end)

Local Script/Text change listener (still couldn’t test it because of this problem):

local lp = game.Players.LocalPlayer
local plrGUI = lp:WaitForChild("PlayerGui")
local dialogues = plrGUI:WaitForChild("Dialogues")
local dialogueText = dialogues.Frame.TextLabel
local text = dialogueText.Text

dialogueText:GetPropertyChangedSignal("Text"):Connect(function()
	print("this is from change listener:",text)
	
	local index = 0
	for first, last in utf8.graphemes(text) do 
		local grapheme = text:sub(first, last) 
		index += 1
		dialogueText.MaxVisibleGraphemes = index
		wait()
	end
end)

Thanks if you tried to help, every answer is appreciated!

Hello, I am not 100% sure If I am getting this issue but I think this should be fixed like this:

In your count value change script, you’re updating text and extServer variables but not applying these new values to the TextLabel.Text property. To update the text displayed by the TextLabel, you must assign the new text directly to TextLabel.Text property.

For example, change:

text = "text1"
textServer = "text1"

To:

dialogueText.Text = "text1"

local lp = game.Players.LocalPlayer
local dialogueCount = lp:WaitForChild("Dialogue Count")
local count = dialogueCount:WaitForChild("DialogueCount")

count:GetPropertyChangedSignal("Value"):Connect(function()
    local dialogueText = lp.PlayerGui.Dialogues.Frame.TextLabel
    
    if count.Value == 1 then
        dialogueText.Text = "text1"
        dialogueText.Visible = true
    elseif count.Value == 2 then
        dialogueText.Text = "text2"
        dialogueText.Visible = true
    elseif count.Value == 3 then
        dialogueText.Text = "text3"
        dialogueText.Visible = true
    elseif count.Value == 4 then
        dialogueText.Text = "text4"
        dialogueText.Visible = true
    end
end)

1 Like

Thank you so much, it’s fixed now!

1 Like

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