Detecting the size of a string

I have made a discord webhook which sends me feedback from users to help me develop my game, but as discord has limits I need to set max text string size to “2000 - (the lenght of the longest possible name in roblox + 2)”. The equation is for me, but I want to detect the size of the string because I saw that if it goes over this 2000 limit it doesn’t even send it. So:

Goal

Make a string lenght detector that will make the local "IsShordEnough" go "false" if the text string is longer than 1950. Or the more complicated variant: divide the string on several messages.

Script:

local Player = game.Players.LocalPlayer
local TextBox = script.Parent.Parent.Parent.DevContactMessageFrame.DevContactMessage --Reference the TextBox where the player types in.
local stringlenght = script.Parent.Parent.Parent.DevContactMessageFrame.DevContactMessage.Text

script.Parent.MouseButton1Click:Connect(function()
    local message = game.Players.LocalPlayer.Name..": "..TextBox.Text
    Remote:FireServer(message)
	
	script.Parent.Send_Roundify_6px.ImageColor3 = Color3.new(0,255,0)
	script.Parent.Text = "Message sent succesfully!"
	script.Parent.TextScaled = true
end)
1 Like

So in order to get the length of the string based on the amount of characters it has, you would use string.len.

4 Likes

Isn’t string.len() what you’re looking for?

4 Likes

I think so yes, I will check it on the developer portal!

1 Like