I’m trying to make a UI with some buttons that will increase and decrease a value like this:
The arrows would make it increase or decrease by a value of 1.
However, the script I made isn’t working. I get no error messages and the value fails to increase or decrease on my UI when I launch the game and click the buttons.
Here is the code:
local segmentCount = game.ReplicatedStorage:WaitForChild("segmentValue")
local segmentCountDisplay = script.Parent.Segment_Number.Text
local increaseSegment = script.Parent.Increase_Segements
local decreaseSegment = script.Parent.Decrease_Segments
function updateText()
segmentCountDisplay = segmentCount.Value
end
updateText()
segmentCount:GetPropertyChangedSignal("Value"):Connect(updateText())
increaseSegment.MouseButton1Click:Connect(function()
segmentCount = segmentCount + 1
end)
decreaseSegment.MouseButton1Click:Connect(function()
segmentCount.Value = segmentCount - 1
end)
And here is the arrangement I have it in my explorer tab:
I also need this value to be called upon because I need to use the value in a different script. If I’m going about this script the wrong way, please let me know.
If anyone is able to help me resolve this issue it would be greatly appreciated. Thanks!
local buttonIncrease = script.Parent.Incease
local buttonDecrease = script.Parent.Decrease
local num = 0
buttonIncrease.MouseButton1Click:Connect(function()
num += 1
script.Parent.Segment_Number.Text = num
end)
buttonDecrease.MouseButton1Click:Connect(function()
num -= 1
script.Parent.Segment_Number.Text = num
end)
That should work better, what you have it too complex for it’s function.
local segmentCountDisplay = script.Parent.Segment_Number.Text
I made this example. Excuse the bad UI, I made it in 2 minutes. The code, and output:
local text = script.Parent.Parent.TextBox.Text
script.Parent.MouseButton1Click:Connect(function()
print (text)
script.Parent.Parent.Frame.TextLabel.Text = text
script.Parent.Parent.Frame.TextLabel.MaxVisibleGraphemes = 0
for i = 1, 250 do
script.Parent.Parent.Frame.TextLabel.MaxVisibleGraphemes += 1
wait(0.2)
end
end)