Help with scrolling text

Hi everyone,

I am trying to make a PID, for a project I’m working on. As you can see in the gif, it only takes a max amount of text then truncates it. If I don’t truncate it, it will cut mid scrolling and go back to the beginning.
https://gyazo.com/c596546df1516ba9206eaefe2df057dc

I cut the GIF short as it only allows six seconds, but I have more text after that.

EDIT : I’ve realized that it’s got to do with the size of the TextBox but if I increase it too much it takes a very long time to display. Is there anyway to count the number of characters and resize the textbox based on that?

This is my script:
    local images = {script.Parent.TextLabel}
    while wait() do 
    	for _,v in pairs(images) do
    		local temp = v.Position.X.Scale
    		if (temp <= -v.Size.X.Scale) then
    			temp = 5 
    		end
    		v.Position = UDim2.new(temp - 0.025 , 0, 0.4, 0) 
     	end
     end

Any help is appreciated, thanks

1 Like

Something like this to set the size of a TextBox based on the area the text takes, TextScaled needs to be off:

 local size = game.TextService:GetTextSize(obj.Text, obj.TextSize, obj.Font,  obj.AbsoluteSize)
 obj.Size = UDim2.new(obj.Size.X.Scale,  obj.Size.X.Offset, 0, size.Y)
 -- resizes only on its Y

Hook this to a GetPropertyChangedSignal(“Text”) to resize after text is inputted.

Edit: Added functional sample

local obj  = something.TextBox

local function resize()
    local size = game.TextService:GetTextSize(obj.Text, obj.TextSize, obj.Font,  obj.AbsoluteSize)
    obj.Size = UDim2.new(obj.Size.X.Scale,  obj.Size.X.Offset, 0, size.Y)    
end


box:GetPropertyChangedSignal(“Text”):Connect(resize) 
# the quotation marks get formatted here, fix them in the script

How would I do this with the current script? Where would I implement it?

For the purpose this is meant to replace the current implementation to resize the TextBox on text being typed.

You can even use TextBox.TextBounds for this:

https://developer.roblox.com/en-us/api-reference/property/TextLabel/TextBounds

1 Like

I’m not sure what you mean. How should I get it working? I’ll also take a look at that, thanks

I’ve tried it and it doesn’t seem to be working. I’ve changed something to script.Parent.TextLabel as that’s the location for the text that scrolls

Nevermind, I used that for scrolling frames and thought it could be altered to suit this case.

You could still do this:

Try increasing the size of the label every x characters, get the characters by

 local len = #label.Text