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

Value not changing to the number in the ui?

Asked by 2 years ago
Edited 2 years ago

The value does not change other values when I put any number in the textbox UI. It just changes all value numbers to 0 instead of the number that is in the textbox. Any thoughts? Here is my code:

local Number = script.Parent.Parent:WaitForChild("TextBox")
local OldValue = game.StarterPack:WaitForChild("OldValue")
local UpdateTo = game.StarterPack:WaitForChild("UpdateTo")
local NewValue = game.StarterPack:WaitForChild("NewValue")

script.Parent.MouseButton1Click:Connect(function()
    Number.Text = OldValue.Value
    wait(0.1)
    OldValue.Value = UpdateTo.Value
    print("Updated Value =", UpdateTo.Value)
    UpdateTo.Value = NewValue.Value
    print("New Value =", NewValue.Value)
end)

Here is the file if needed: https://drive.google.com/file/d/1SRnYcp7oA0tukRTA2hXX7z7vXX2rs5wc/view?usp=sharing

1 answer

Log in to vote
0
Answered by 2 years ago

I found the problem. I put Number.Text = OldValue.Value instead of OldValue.Value = Number.Text and for the code, the script meant that it needs to change the text instead of the value. I also changed the number value to an int value.

Here is my fixed code:

local Number = script.Parent.Parent:WaitForChild("TextBox")
local OldValue = game.StarterPack:WaitForChild("OldValue")
local UpdateTo = game.StarterPack:WaitForChild("UpdateTo")
local NewValue = game.StarterPack:WaitForChild("NewValue")

script.Parent.MouseButton1Click:Connect(function()
    OldValue.Value = Number.Text
    wait(0.1)
    UpdateTo.Value = OldValue.Value
    print("Updated Value =", UpdateTo.Value)
    NewValue.Value = UpdateTo.Value
    print("New Value =", NewValue.Value)
end)
Ad

Answer this question