Can't change Text with values

Hello there! Thank you for take the time to read this :slight_smile: . Well i’m currently having a problem. So I have a script that changes some Texts by some Values.

I would like to know how to fix this issue. So when I test the game, the texts doesnt change, but the values do.

image

image

If I reload the script while playing, the texts changes to the correct value.

Here’s my script

-- Services
local players = game:GetService("Players")
local player = players.LocalPlayer

-- Variables for Questions
local MainFrame = script.Parent
local Accept = script.Parent:WaitForChild("Accept")
local decline = script.Parent:WaitForChild("Decline")
local information = script.Parent:WaitForChild("Information")

--Variables for LeftSide
local leftside = script.Parent.Parent:WaitForChild("LeftSide")
local CompletedNumber = leftside:WaitForChild("CompletedNumber")
local OutOfNumber = leftside:WaitForChild("OutOfNumber")
local Reward = leftside:WaitForChild("Reward")
local Info2 = leftside:WaitForChild("Information2")

-- Folder for values
local QuestFolder = script.Parent:WaitForChild("Quests")
local OneFolder = QuestFolder:WaitForChild("One")
local TwoFolder = QuestFolder:WaitForChild("Two")
local ThreeFolder = QuestFolder:WaitForChild("Three")
-- Setting Up Values for text

CompletedNumber.Text = CompletedNumber.Value.Value
OutOfNumber.Text = OutOfNumber.Value.Value
Reward.Text = Reward.RewardValue.Value


if OneFolder.Completed.Value == false then
	information.Text = OneFolder.Quest.Value
	Reward.RewardValue.Value = 100
end

*Any help is appreciated :smiley: If you need more details, let me know

2 Likes

The issue could be here;

if OneFolder.Completed.Value == false then
	information.Text = OneFolder.Quest.Value
	Reward.RewardValue.Value = 100
end

It looks to me that you’re updating the text before the actual value is set, try reversing to the following code instead:

if OneFolder.Completed.Value == false then
    Reward.RewardValue.Value = 100
	information.Text = OneFolder.Quest.Value
end
3 Likes

image
Did you accidentally add an extra .Value here?

3 Likes

No. CompletedNumber is a textlabel, it includes a value called “Value”… I didn’t add a name into it.

2 Likes

Hmm I tried it as well, but It keeps the same. I need to reload the script so it works :confused:

1 Like

I forgot to mention, what is the error?

2 Likes

Well. I’m trying to change the Text from some TextLabels with some values. The script changes the value for the text. In this case I want it to be 100… Then “100” should appear on the text.

But the value is the only one that changes, the text keeps saying “TextLabel” untill I reload the script.

1 Like

Perhaps it is due to the script only running once at a time?

   OneFolder.Completed.Value.Changed:Connect(function(Value)
	if OneFolder.Completed.Value == false then
		information.Text = OneFolder.Quest.Value
		Reward.RewardValue.Value = 100
	end
end)

This could possibly be a fix?

2 Likes

Well, I tried to do that and it stills the same, I don’t really know why it happens.

1 Like

I tried to put a localscript on the text label as well and put the .Changed function or the script.Parent.Text = RewardValue.Value. But it keeps as text label :confused:

Is the original piece of code held in a LocalScript or a ServerScript?

1 Like

Ah, the code I have is in a local script.

Ah, so you shouldn’t be reading Values from the client, it’s best to do it from the Server, however the changing of the TextLabel should be on the Client.

1 Like

Ohh. Thank you!. :smiley: I think I should try using remote events, or just write the text on the script. :smiley:

Yes, attempt doing that and then let me know if that works out! :slight_smile:

1 Like

Thank you! Im changing the text from the script and it works now.!
image

Glad I could be of assistance to you!

1 Like