Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Checking the length of text not working, why?

Asked by 5 years ago

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)
0
.len is not a property of string but a method. you need to use parentheses to call it, button.Parent.OrderInfo.Text:len() GoldAngelInDisguise 297 — 5y
0
^ Fifkee 2017 — 5y

1 answer

Log in to vote
0
Answered by
Imperialy 149
5 years ago

this should help

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

Answer this question