I do not receive any errors while attempting to run this function, but the values do not increase.
-- In a LocalScript in StarterGui:
-- Create ScreenGui
local screenGui = Instance.new("ScreenGui")
screenGui.Parent = script.Parent
-- Create RedValue
local redValue = 0
-- Create RedInput
local redInput = Instance.new("TextLabel")
redInput.Name = "Red"
redInput.Parent = screenGui
redInput.Position = UDim2.new(0.5,-100,0.5,-75)
redInput.Size = UDim2.new(0,200,0,50)
redInput.BackgroundColor3 = Color3.new(255,0,0)
redInput.Text = ("Red Value = " .. redValue)
-- Create RedInputLeftArrow
local redLess = Instance.new("TextButton")
redLess.Name = "Red Reduce by One"
redLess.Parent = screenGui
redLess.Position = UDim2.new(0.5, -150, 0.5, -75)
redLess.Size = UDim2.new(0, 50, 0, 50)
redLess.BackgroundColor3 = BrickColor.White().Color
redLess.Text = "<"
-- Bind function to button click
redLess.MouseButton1Down:connect(function()
if redValue == 0 then
elseif redValue >0 and redValue <=255 then
redValue = redValue-1
end
end)
-- Create RedInputRightArrow
local redMore = Instance.new("TextButton")
redMore.Name = "Red Increase by One"
redMore.Parent = screenGui
redMore.Position = UDim2.new(0.5, 100, 0.5, -75)
redMore.Size = UDim2.new(0, 50, 0, 50)
redMore.BackgroundColor3 = BrickColor.White().Color
redMore.Text = ">"
-- Bind function to button click
redMore.MouseButton1Down:connect(function()
if redValue == 255 then
elseif redValue <255 and redValue >=0 then
redValue = redValue+1
end
end)
I can guess the values probably need to be local, if that is the solution, please answer and I will upvote you.

1 comment
Add prints