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