Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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....

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 123nabilben123 499 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

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!

0
your .Changed function isn't worked plz help ! inconue88 3 — 4y
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 Sensei_Developer 298 — 4y
0
no I tried again and again but it doesn't worked ..... inconue88 3 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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)
0
I believe you didn't change the Price Value. Sensei_Developer 298 — 4y
0
Nope I've changed the value but nothing Happen inconue88 3 — 4y

Answer this question