Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How could I make a When numberValue.value changed then SurfaceGui.Textlabel.text=NumberValue.Value?

Hi plz Help me I am searching an issue with My script because I cannot make it work I don't have error but it does'nt work plz check it

while true do

local Price = game.ReplicatedStorage.Price
local amount = game.Workspace.Shop.Product.CashRegister.price.SurfaceGui.TextLabel

while true do
amount.Text = Price.Value
wait()
end

wait()
end

and I've tried in this wait too but it doesn't worked

while true do

local Price = game.ReplicatedStorage.Price
local amount = game.Workspace.Shop.Product.CashRegister.price.SurfaceGui.TextLabel

amount.Text = Price.Value


wait()
end

I cannot make it when the value change then the text change too....

2 comments

0

So what are you trying to do? If your script doesn't work then include print() statements in your script to see where the errors falls at. This is called Print Debugging

2 answers

Hey buddy.

I see you're having trouble with the value stuff.

Let me tell you about this amazing function called .Changed. It detects when an item has changed, then fires a function. For example;

game.ReplicatedStorage.Price.Changed:Connect(function()
	print("Value has changed to "..game.ReplicatedStorage.Price.Value)
end

This way, you don't need to use while loops anymore! How cool is that?

So, now let's put the .Changed function into your script!

local Price = game.ReplicatedStorage.Price
local Amount = game.Workspace.Shop.Product.CashRegister.price.SurfaceGui.TextLabel.Text

Price.Changed:Connect(function()
	Amount = "$"..Price.Value
end)

By the way, if you're wondering about that .., that is sort of like telling the script to "Hey, insert this Value into this part of the text."

If you're still stuck, feel free to message me back!

3 comments

0

your .Changed function isn't worked plz help !

0

What? Did you do something wrong in this script? Perhaps you mispelled something. Try re-writing the script. Hopefully that works. Regrets, Sensei_Developer

0

no I tried again and again but it doesn't worked .....

So Sensei_Developer, I've tried your script and it doesn't worked too but thanks to learning me the .Changed function. So When I copy and pasted your script I launched the game I go to my surface gui that need to show the value ,I changed my Value in replicatedStorage and ..... he didn't changed anything

here is your script and what I changed to see where is the error :


local Price = game.ReplicatedStorage.Price
local Amount = game.Workspace.Shop.Product.CashRegister.price.SurfaceGui.TextLabel
print("TEST1")

--- after printing "TEST1" It didn't print("TEST2")

Price.Changed:Connect(function()
    Amount.Text = Price.Value
print("TEST2")
end)

2 comments

0

I believe you didn't change the Price Value.

0

Nope I've changed the value but nothing Happen

This discussion is preserved as it was. New answers, comments, and votes are closed.