So, I'm making a custom chat, but instead of making it simple I want to have the player's name a different color/font to the rest of the message. This somehow works perfectly in studio but does not work properly in online mode as seen in this place. How do I fix this problem, here's my function which returns no errors, works perfectly in studio but not in online mode:
function addMessage(speaker,msg,chat,color)
for i,v in pairs(chat:GetChildren()) do
if v:IsA("Frame") and string.sub(v.Name,1,7) then
v.ActualPosition.Value = v.ActualPosition.Value-32
v:TweenPosition(UDim2.new(0,5,0,v.ActualPosition.Value),"Out","Sine",0.5,true)
v.Name = "Message"..tostring(tonumber(string.sub(v.Name,8))+1)
if v.Name == "Message6" then
v:TweenPosition(UDim2.new(0,5,0,-62),"Out","Sine",0.5,true)
game:GetService("Debris"):AddItem(v,0.5)
end
end
end
local ChatFrame = Instance.new("Frame",chat)
ChatFrame.Name = "Message1"
ChatFrame.BackgroundTransparency = 1
ChatFrame.Position = UDim2.new(0,5,0,149)
ChatFrame.Size = UDim2.new(0,0,0,32)
local ActualPosition = Instance.new("IntValue",ChatFrame)
ActualPosition.Name = "ActualPosition"
ActualPosition.Value = 149
local Name = Instance.new("TextLabel",ChatFrame)
Name.Name = "Name"
Name.BackgroundTransparency = 1
Name.TextColor3 = color
Name.TextStrokeTransparency = 0.5
Name.Font = "SourceSans"
Name.FontSize = "Size18"
Name.Text = speaker
Name.Size = UDim2.new(0,Name.TextBounds.X,0,Name.TextBounds.Y)
Name.ZIndex = 2
local Message = Instance.new("TextLabel",ChatFrame)
Message.Name = "Message"
Message.BackgroundTransparency = 1
Message.TextColor3 = Color3.new(255,255,255)
Message.Font = "SourceSansLight"
Message.FontSize = "Size18"
Message.TextXAlignment = "Left"
Message.TextYAlignment = "Top"
Message.TextWrapped = true
Message.Text = msg
Message.Size = UDim2.new(0,350,0,36)
Message.Position = UDim2.new(0,Name.TextBounds.X+2,0,0)
Message.ZIndex = 2
local Shadow = Message:Clone()
Shadow.Parent = Message
Shadow.TextColor3 = Color3.new(0,0,0)
Shadow.Position = UDim2.new(0,-1,0,1)
Shadow.ZIndex = 1
end
If you really want to see the rest of the script go here, although I don't see any reason why the rest of it would affect it. THIS IS IN A SERVER SCRIPT!

8 comments
2 Up votes. This Question should be answered. I'll up vote the right answer as well.
Tsk, tsk. I remember when as soon as you posted a script with more than 30 lines, everyone hated you. This is unfair.
Is this a Script or a LocalScript?
Also, what errors did you find when pressing F9 (opening dev console)
@LordDragonZord; it's all about context. This script may be 50 lines long, but a lot of those lines are only setting properties of newly created objects.
@OP; Is this a LocalScript, and is Filtering enabled?
@adark, that's no fair, I deserve those 20+ reputation back.
@TheDeadlyPanther, There are no errors in the dev console, @ALL This is in a Server Script (normal script), @adark Filtering is disabled.