I have a chat GUI that, when someone chat's, a TextLabel is created in which will contain what the player said. Though, i would like that when each line that the text creates, it resizes the Y of the text box accordingly, so it doesn't have a static Y size and when the player chats a short message, there isn't a giant gap between each message.
Script:
wait(2)
chatBoxGui = script.Parent.ExampleGui
chatEvent = game.Workspace:WaitForChild("OnChatted")
receiveChat = game.Workspace:WaitForChild("SendChatToEveryone")
amountOfChats = 0
canChat = true
function CreateNewChat(args)
local newChat = chatBoxGui:clone()
newChat.Parent = script.Parent.Parent.Chats
newChat.Position = UDim2.new(0,0,0,amountOfChats*50)
newChat.Text = args[1]..": "..args[2]
newChat.Visible = true
amountOfChats = amountOfChats+1
end
receiveChat.OnClientEvent:connect(function (args)
CreateNewChat(args)
end)
script.Parent.Parent.TextButton.MouseButton1Click:connect(function()
if not canChat then return end
canChat = false
chatEvent:FireServer({game.Players.LocalPlayer.Name,script.Parent.Text})
wait(2)
canChat = true
end)

1 comment
Thanks!