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

How do I make this not require a then instead of an equals sign?

This is just a subsection of a script I'm making. If all goes well, if redValue=0 then will be on line 37.

-- In a LocalScript in StarterGui:
 
-- Create ScreenGui
local screenGui = Instance.new("ScreenGui")
screenGui.Parent = script.Parent
 
-- Create ColorBox
local colorBox = Instance.new("Frame")
colorBox.Name = "Color"
colorBox.Parent = screenGui
colorBox.Position = UDim2.new(0, 0, 0.5, -75)
colorBox.Size = UDim2.new(0, 150, 0, 150)
colorBox.BackgroundColor3 = Color3.new(0,0,0)

-- 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 = ""

-- Create RedInputLeftArrow
local redLess = Instance.new("TextButton")
redLess.Parent = screenGui
redLess.Position = UDim2.new(0, 50, 0, 50)
redLess.Size = UDim2.new(0.5, -150, 0.5, -25)
redLess.BackgroundColor3 = BrickColor.White().Color
redLess.Text = "<"
 
-- Bind function to button click
redLess.MouseButton1Down:connect(function()
	if redValue=0 then
		
	elseif redValue >0 and <=255 then
		redValue = redVlaue-1
	end
end)

Line 37 is giving me the error "Error: (37,13) Expected 'then', got '='"

Any idea as to how I can fix this?

1 answer

✓ Accepted answer

You misused the operator for the conditional. == is the operator used for comparing two values to see if they are equal, not =. = is used for assigning things.

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