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

Checking the length of text not working, why?

So basically I am creating a button so when you click it, it checks if you selected a type of art then it checks if actually entered something into the info box. If I select a type with or without entering the info and I click order it gives this error: Players.TypicallyPacific.PlayerGui.ScreenGui.StandardOrder.Order.LocalScript:5: attempt to compare number with function. How would I fix this?

local button = script.Parent

button.MouseButton1Click:Connect(function(player)
	if button.Parent.Values.Type.GFX.Value == true or button.Parent.Values.Type.Drawing.Value == true then
		if button.Parent.OrderInfo.Text.len >= 1 then
			button.BackgroundColor3 = Color3.fromRGB(85, 255, 127)
			wait(2)
			button.BackgroundColor3 = Color3.fromRGB(227, 227, 227)
		else
			button.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
			button.Parent.OrderInfo.BackgroundColor3 = Color3.fromRGB(255, 0 ,0)
			wait(2)
			button.BackgroundColor3 = Color3.fromRGB(227, 227, 227)
			button.Parent.OrderInfo.BackgroundColor3 = Color3.fromRGB(227, 227, 227)
		end
		else
		button.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
		button.Parent.Drawing.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
		button.Parent.GFX.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
		button.Parent.Type.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
		wait(2)
		button.BackgroundColor3 = Color3.fromRGB(227, 227, 227)
		button.Parent.Drawing.BackgroundColor3 = Color3.fromRGB(227, 227, 227)
		button.Parent.GFX.BackgroundColor3 = Color3.fromRGB(227, 227, 227)
		button.Parent.Type.BackgroundColor3 = Color3.fromRGB(227, 227, 227)
	end
end)

2 comments

0

.len is not a property of string but a method. you need to use parentheses to call it, button.Parent.OrderInfo.Text:len()

0

^

1 answer

this should help

local text = button.Text
print(string.len(text))

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