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

Value not changing to the number in the ui?

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

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)

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