So, im trying to change the text inside of a textlabel using a script, but it's not working, there are no errors inside of the output so there is nothing i know what i can do, here is my script, is there a problem with it?
local red = game:GetService("ReplicatedStorage").PointValues:FindFirstChild("RedPoints") game.ReplicatedStorage.PointValues.RedPoints.Value.Changed:Connect(function() script.Parent.Text = red.Value end)
Hi! I think you have some problem that's is in the script, anyways, let fix this!
The script (not the answer, I just put here so that's make a lot of easier instead of always scrolling up to see this script.):
local red = game:GetService("ReplicatedStorage").PointValues:FindFirstChild("RedPoints") game.ReplicatedStorage.PointValues.RedPoints.Value.Changed:Connect(function() script.Parent.Text = red.Value end)
Line 3: You already have located 'RedPoints', and you need to use :GetService("ReplicatedStorage")
instead of ReplicatedStorage
. If the 'RedPoints' is already in the ReplicatedStorage while you're not in playing or running mode, then you'll just short-form the line 1, :FindFirstChild("RedPoints")
to RedPoints
. That's doesn't matter if you also use the :FindFirstChild()
in line 1.
@StoicSage said, "Assuming that 'red' is an IntValue or NumberValue, you need to change it into a string". So, if that's an IntValue or NumberValue, then just place the tostring()
inside! I don't need to describe anymore in here, you can just see the @StoicSage's answer.
You can just use while wait() do
if you need to set the text to the "RedPoints'" value every time when the value was changed.
Yeah! Try to use those three ways to fix your problem! Let me repeat but short, use tostring()
if 'RedPoints' was an IntValue or NumberValue, or use while wait() do
when there you need to change the text while the "RedPoints" was changed.
If this fixes your issue, please mark this as correct so that might let everyone know that's this is the correct answer!
And please leave an upvote. I don't like to say, but it helps a lot! Thanks! :)
By the way, please don't blame me if there have no answer here, the script might not working if that not suits yours.
Yeha! So, I'm Jack_Roblox2008, see ya next time, bye bye!
Assuming that 'red' is an IntValue or NumberValue, you need to change it into a string.
To do so, use tostring()
local red = game:GetService("ReplicatedStorage").PointValues:FindFirstChild("RedPoints") game.ReplicatedStorage.PointValues.RedPoints.Value.Changed:Connect(function() script.Parent.Text = tostring(red.Value) end)
The problem is that you're trying to use the Event .Changed on a property. That is not how it works. Also if you already set a variable for red. You should use it. Try this code instead.
local red = game:GetService("ReplicatedStorage").PointValues:FindFirstChild("RedPoints") red.Changed:Connect(function() script.Parent.Text = red.Value end)