generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: TextBounds not working for me

Previous Thread :: Next Thread 
TheDefence is not online. TheDefence
Joined: 07 Sep 2013
Total Posts: 47
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
TheDefence is not online. TheDefence
Joined: 07 Sep 2013
Total Posts: 47
13 Dec 2015 12:51 PM
Help please?
Report Abuse
TheDefence is not online. TheDefence
Joined: 07 Sep 2013
Total Posts: 47
13 Dec 2015 01:36 PM
Why is it that nobody ever helps me out when I need it?
Report Abuse
BRAYONCE is not online. 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
TheDefence is not online. TheDefence
Joined: 07 Sep 2013
Total Posts: 47
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 is not online. 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
TheDefence is not online. TheDefence
Joined: 07 Sep 2013
Total Posts: 47
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image