Creating a command line/log box

Hello, I’m trying to create a log box for an upcoming project of mine. Ideally, this log box would act like a linux terminal, with text appearing at the bottom and it autoscrolling.
I already have an idea how it would be done using textlabels and scrolling frames and I’m just posting this to see if there are any better ways of doing this

3 Likes

You are trying to log when the player chats? If so you can use a Player.Chatted event in ServerScriptService, then for looping through all the people who have the log gui and created a new TextLabel. Then setting the Message to that text.

game.Players.PlayerAdded:Connect(function(Player)
   Player.Chatted:Conncet(function(Msg)
   for i,v in pairs(game.Players:GetPlayers()) do
   if v.PlayerGui:FindFirstChild("Logs") then
   Instance.new . . .
end
end
end)
end)

You can also do a userid check.

No, I’m not trying to log chat, I’m looking for help on making a log box that behaves like a terminal window. As in, it the text appears at the bottom and it auto scrolls. I have no problems with logging data. I just need feedback on how one would make such a box that acts like that.

Ahh I think I see what you mean, 300px-Windows_Terminal_0.4_screenshot something like this?
it would probably take some encoding, httpservice I don’t really know sorry.

Yes, in that style.
However, the data will be sent over remote events, so httpservice will not be needed.
I just need a way to recreate that kind of box (with autoscroll, etc.) in roblox

A ScrollingFrame is a perfect way to make one of these, you could easily have a TextLabel which has the Size of {1, 0}, {1, 0} to fill the whole window.

Then, in a LocalScript Connect on GetPropertyChangedSignal for the Text on the TextLabel and adjust the ScrollingFrame’s CanvasSize to {0, 0}, {0, TextLabel.TextBounds.Y}. With that, it’ll be scrollable to the exact bottom of the Text (just like a command line). Making it autoscroll will just require you to assign the CanvasPosition to a Vector2 with the Y set to CanvasSize.Y (or TextBounds.Y).

For example:

TextLabel:GetPropertyChangedSignal("Text"):Connect(function()
    local YSize = TextLabel.TextBounds.Y;
    ScrollingFrame.CanvasSize = UDim2.new(0, 0, 0, YSize);
    ScrollingFrame.CanvasPosition = Vector2.new(0, YSize)
end)

Let me know how it goes!

2 Likes

Wow! Thanks!
I thought I had to use multiple TextLabels but this is a much better solution.

Wouldn’t you use multiple labels? Then assigning the whole scrollingframe’s canvassize to just one single label’s Y height wouldn’t be ideal would it?

Why would you need to use multiple TextLabels? The TextBound property represents the Text’s space on the Screen in Pixels with the Y property being the absolute bottom the the Text, you may need to add a little offset for some letters.

If you were to use multiple TextLabels, the process would be much tougher requiring you to find the product of the TextLabels’ TextBounds while making sure they don’t use the same Y space.

Didn’t OP mean something like this though? Where you’d see multiple textlabels stacked above each other within a scrollingframe? Or am I completely mistaken?

That could be created by using \n to make a new line.

Oh, really? Do textlabels support multi-line using \n?

Yes, they do.
(30 chars asdsadsdasdsd)