Object does not exist when the path to the object is correct

Hey, I am creating a custom chat gui.

The issue is that I am following the correct path to reach a frame called ‘Main’, yet the script thinks it doesn’t exist…

Here is my code:

local rs = game:GetService("ReplicatedStorage")
local msgTemplate = script:WaitForChild("Message")

local uis = game:GetService("UserInputService")

local chat = script.Parent:WaitForChild("Chat")
local list = chat:WaitForChild("Main"):WaitForChild("List") -- This line

rs:WaitForChild("LogChatRE").OnClientEvent:Connect(function(sender, message)
	if sender and message then
		local temp = msgTemplate:Clone()
		temp.MessageText.Text = tostring(sender.Name)..": "..tostring(message)
		temp.Parent = list
	end
end)

uis.InputBegan:Connect(function(input, GPE)
	if input.KeyCode == Enum.KeyCode.Return then
		print("Enter pressed!")
	end
end)

Here is the heirarchy:

So in localscript:

local Player = game:GetService("Players").LocalPlayer
Main = Player.PlayerGui.Chat.Main

The same error logs (30jsjasaj chars)

Is the script working?
Try placing a Print on the first line, sometimes localscripts are not replicated.

There may be a name collision between your interface and the default chat GUI, which is also called “Chat.” Have you overridden the default chat script yet?

1 Like

Ok that was the problem. It works now thanks!

1 Like