So I have this Custom Chat GUI, but I've encountered a very annoying problem. When everything works fine in the studio, it doesn't in the game! I've done solutions such as adding
repeat wait() until game.Players.LocalPlayer ~= nil
, repeat wait() until game.Players.LocalPlayer:WaitForChild("Character")
, local ChildofPlayer = game.Players.LocalPlayer:FindFirstChild("Character")
, at the beginning. Even adding a wait() at the beginning and end didn't help. This has really gotten me very annoyed and I've tried to research this for over a day. Also, nothing shows up in Output except some infinite yield error when I use a WaitForChild.
local Player = game.Players.LocalPlayer local ChildofPlayer = Player:GetChildren("Character") local chatbox6 = script.Parent.Parent.MsgChatFrame.chatbox6 script.Parent.msgbar.FocusLost:Connect(function(enter) if enter then script.Parent.Parent.MsgChatFrame.chatbox1.Text = script.Parent.Parent.MsgChatFrame.chatbox2.Text script.Parent.Parent.MsgChatFrame.chatbox2.Text = script.Parent.Parent.MsgChatFrame.chatbox3.Text script.Parent.Parent.MsgChatFrame.chatbox3.Text = script.Parent.Parent.MsgChatFrame.chatbox4.Text script.Parent.Parent.MsgChatFrame.chatbox4.Text = script.Parent.Parent.MsgChatFrame.chatbox5.Text script.Parent.Parent.MsgChatFrame.chatbox5.Text = script.Parent.Parent.MsgChatFrame.chatbox6.Text script.Parent.Parent.MsgChatFrame.chatbox6.Text = script.Parent.msgbar.Text script.Parent.msgbar.Text = "Tap the \"/\" button or click here to chat" chatbox6.Text = " "..Player.Name..": "..chatbox6.Text end end)
Someone please help, because I can't stand it
GetChildren only returns a table of the children inside the instance; you can't enter the name of the child as a parameter. Instead, if you just want to search for a child, you should use FindFirstChild or WaitForChild. However, the Character is a property of the player that points to the character model, and is not actually inside the player. A good way to wait for the character is by doing something like:
local plr = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait() local character = plr.Character or plr.CharacterAdded:Wait()
This will set the character variable to the player's character if it has been loaded, otherwise it will wait for the character to be added and return it when it is.