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

I'm trying to make a GUI that has the same text as a value, but it doesn't change. Help?

Asked by 3 years ago

I'm trying to make a GUI that displays a value. I put the value in the text label and this is my script.

local oxygen = script.Parent.Oxygen.Value

script.Parent.Oxygen.Changed:Connect(function() script.Parent.Text = oxygen end)

for some reason when the value changes the text label does not change. How am I supposed to make this?

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

This issue is somewhat common. Don't define the oxygen value there. Define the oxygen variable inside the function. Another solution is doing script.Parent.Text = script.Parent.Oxygen.Value. When setting a variable to a value's value, it gets set when/where it is defined and that is it. When setting a variable to the object, it becomes what i call an object reference.

local part = workspace.Part part and workspace.Part are the same thing. You can do part.Color=(color) or workspace.Part.Color=(Color) and it will do the same thing. But when you do local val = workspace.NumVal.Value with the workspace.NumVal's value being 10, val becomes 10. If workspace.NumVal's value gets updated, val will not change until re-defined

Ad
Log in to vote
0
Answered by
epoke466 100
3 years ago

I'm new to scripting and I don't know if this will work but here is what I got

local oxygen = script.Parent.Oxygen

function change ()
    script.Parent.Text = oxygen.Value
end

script.Parent.Oxygen.Changed:Connect(change)

Answer this question