|
| 13 Dec 2015 11:33 AM |
Basically, it always sets the size to (1,0,0,20) no matter what. Here's the code:
local StarterGui = game:GetService("StarterGui") local UIS = game:GetService("UserInputService") local StarterGui = game:GetService("StarterGui") local ChatEvent = game.ReplicatedStorage:WaitForChild("Chat") local GuiArea = game.Players.LocalPlayer.PlayerGui.ZT_Gui.ChatContainer local defaulttext = tostring(script.Parent.Text) local NoC = script.Parent.NoCval.Value
StarterGui:SetCoreGuiEnabled("Chat",false)
script.Parent.FocusLost:connect(function(entered) if entered and script.Parent.Text ~= "" then ChatEvent:FireServer(script.Parent.Text) script.Parent.Text = defaulttext else wait(0.05) end wait() script.Parent.Text = defaulttext end)
UIS.InputBegan:connect(function(key,GPE) if not GPE and key.KeyCode == Enum.KeyCode.Slash then script.Parent:CaptureFocus() end end)
ChatEvent.OnClientEvent:connect(function(Sender, Message) local ChatExample = game.ReplicatedStorage.ChatExample:Clone() ChatExample.Text = (Sender.Name..": "..Message) if ChatExample.TextBounds.X < 500 then ChatExample.Size = UDim2.new(1,0,0,20) elseif ChatExample.TextBounds.X == 500 and ChatExample.Size == UDim2.new(1,0,0,20) then ChatExample.Size = UDim2.new(1,0,0,40) else ChatExample.Size = UDim2.new(1,0,0,60) end local NewChat = ChatExample:Clone() NoC = NoC + 1 NewChat.Name = NoC NewChat.Parent = GuiArea NewChat.Text = (Sender.Name..": "..Message) local LC = GuiArea[tostring(NoC-1)] if ChatExample.Size == UDim2.new(1,0,0,20) then NewChat.Position = LC.Position + UDim2.new(0,0,0,20) elseif ChatExample.Size == UDim2.new(1,0,0,40) then NewChat.Position = LC.Position + UDim2.new(0,0,0,40) elseif ChatExample.Size == UDim2.new(1,0,0,60) then NewChat.Position = LC.Position + UDim2.new(0,0,0,60) end end) |
|
|
| Report Abuse |
|
| |
|
| 13 Dec 2015 01:36 PM |
| Why is it that nobody ever helps me out when I need it? |
|
|
| Report Abuse |
|
BRAYONCE
|
  |
| Joined: 18 Apr 2011 |
| Total Posts: 1551 |
|
|
| 13 Dec 2015 01:40 PM |
TextBounds can only be found through localscript- that is what I found when making my own chat at least..
#code Forums.BRAYONCE.Response:FireClient(response) |
|
|
| Report Abuse |
|
|
| 13 Dec 2015 01:45 PM |
This is a local script.
Does your chat have multi-line support? That's what I'm trying to achieve here. |
|
|
| Report Abuse |
|
BRAYONCE
|
  |
| Joined: 18 Apr 2011 |
| Total Posts: 1551 |
|
|
| 13 Dec 2015 01:53 PM |
Mine does have multi line support;
I have a gui set up, everyone has 9 lines in their chat box;
In a script in workspace, once someone talks it calls a function to run through everyones gui's and bump the previous chat up- this takes the sizes from all previous messages and transfers them up one;
If their msg:length() > 50 then it bumps again, this time making the player tag nil and the message is just the size (1,0,1,0)
In the chat lines 9 to 7; there is a local script that re-sizes it; so when the global script bumps up sizes it is done accurately.
If that helps- it helps. But I'm obviously not a teacher because explaining is not my thing.
#code Forums.BRAYONCE.Response:FireClient(response) |
|
|
| Report Abuse |
|
|
| 13 Dec 2015 02:33 PM |
| Length is quite inaccurate as some characters are longer than others, this is why I am using TextBounds, but they don't seem to be working for me. |
|
|
| Report Abuse |
|