vastqudJoin Date: 2011-09-10 Post Count: 2464 |
game:GetService('Players').PlayerAdded:connect(function(player)
player.Chatted:connect(function(msg)
for _,v in ipairs(game:GetService("Players"):GetChildren()) do
for i,oldmsg in ipairs(v:WaitForChild("PlayerGui").CustomChat.Frame:GetChildren()) do
oldmsg.Position = oldmsg.Position - UDim2.new(0,0,0,15)
end
local newchatline = Instance.new("TextLabel",v:WaitForChild("PlayerGui").CustomChat.Frame)
newchatline.Text = player.Name.. " : " ..msg
newchatline.Size = UDim2.new(3.9,0,0,50)
newchatline.Position = UDim2.new(0,0,0,50)
newchatline.Font = "SourceSansBold"
newchatline.TextColor3 = Color3.new(0.1,0.9,1)
newchatline.TextStrokeTransparency = 0
newchatline.BackgroundTransparency = 1
newchatline.BackgroundColor3 = Color3.new(0.2,1,1)
newchatline.BorderSizePixel = 0
newchatline.FontSize = "Size18"
newchatline.TextXAlignment = "Left"
newchatline.TextYAlignment = "Top"
newchatline.ClipsDescendants = true
newchatline.Name = "line1"
end
end)
end)
there are no errors, and it used to work a couple months ago
it works in studio mode but not while online, and I assume it has something to do with the first line of code there... |
|
vastqudJoin Date: 2011-09-10 Post Count: 2464 |
in the server log it says that customchat is not a valid member of playergui
in studio play solo, it is |
|
vastqudJoin Date: 2011-09-10 Post Count: 2464 |
this is odd
I put a script into CustomChat saying print(script.Parent:GetFullName()), and while in online mode I looked at the dev console, and it says game.Players.vastqud.PlayerGui.CustomChat
yet, in the server log, it says CustomChat is not a valid member of PlayerGui
why? |
|
CasualistJoin Date: 2014-06-26 Post Count: 4443 |
Here's what is happening.
Player joins game, player starts to load
You assume that once the PlayerGui is created everything that is going to be in it is instantaneously there.
You look for it, fail, and error out.
PlayerGui things load over time, and you see their output because they do eventually exist.
This should have been made obvious when the time stamps showed the server errored out before the script printed the full path. |
|
vastqudJoin Date: 2011-09-10 Post Count: 2464 |
kthnx |
|
vastqudJoin Date: 2011-09-10 Post Count: 2464 |
alright so I added :WaitForChild's in there where needed, but it still doesn't work
again, it still prints to full name of the screen gui, which is inside of the playergui
there are no more errors, but it just doesn't work |
|
CasualistJoin Date: 2014-06-26 Post Count: 4443 |
This means that the script is hung up on a WaitForChild. Add a print statement before each one to figure out which one hangs, and then you can further address the problem (also, you can use Studio->Test->Start with 1+ players so studio behaves like online mode, but you get to see but the client and server states). |
|
vastqudJoin Date: 2011-09-10 Post Count: 2464 |
after I do that, how can I fix the one that hangs? |
|
vastqudJoin Date: 2011-09-10 Post Count: 2464 |
k, so I did that, and it prints "1" each time, and 1 is the print before the first one. it never prints 2
does that mean its hung up on number 1 or 2? |
|
CasualistJoin Date: 2014-06-26 Post Count: 4443 |
Post code. If the print statements are before the WaitForChilds, it hangs on the first WaitForChild |
|
vastqudJoin Date: 2011-09-10 Post Count: 2464 |
alright here it is:
game:GetService('Players').PlayerAdded:connect(function(player)
player.Chatted:connect(function(msg)
for _,v in ipairs(game:GetService("Players"):GetPlayers()) do
print("1")
for i,oldmsg in ipairs(v:WaitForChild("PlayerGui"):WaitForChild("chat").Frame:GetChildren()) do
oldmsg.Position = oldmsg.Position - UDim2.new(0,0,0,15)
if oldmsg.Position == UDim2.new(0,0,0,5) then
oldmsg:Destroy()
end
end
print("2")
local newchatline = Instance.new("TextLabel",v:WaitForChild("PlayerGui"):WaitForChild("chat").Frame)
newchatline.Text = player.Name.. " : " ..msg
newchatline.Size = UDim2.new(3.9,0,0,50)
newchatline.Position = UDim2.new(0,0,0,50)
newchatline.Font = "SourceSansBold"
newchatline.TextColor3 = Color3.new(0.1,0.9,1)
newchatline.TextStrokeTransparency = 0
newchatline.BackgroundTransparency = 1
newchatline.BackgroundColor3 = Color3.new(0.2,1,1)
newchatline.BorderSizePixel = 0
newchatline.FontSize = "Size18"
newchatline.TextXAlignment = "Left"
newchatline.TextYAlignment = "Top"
newchatline.ClipsDescendants = true
newchatline.Name = "line1"
end
end)
end)
|
|
CasualistJoin Date: 2014-06-26 Post Count: 4443 |
Originally you where trying to look for "CustomChat", but in your lastest post you call WaitForChild with "chat" if you haven't changed the name of the object to "chat" it won't find it. |
|
vastqudJoin Date: 2011-09-10 Post Count: 2464 |
I did change the name, sorry if that confused you |
|