I can't find objects in a clone

Cloning doesn’t automatically parent the cloned instance, just parent chatMessage to where ever you want it to be.

local chatMessage = storage.ChatMessage:Clone()

chatMessage.Author.Name.Badge.Visible = true

chatMessage.Parent = --parent it here

I know that, it is just that the script can’t find any of the children inside it. If I remove everything else than cloning and parenting, then it clones fully. When I try to change anything inside it with the script, it fails.


local chatMessage = storage.ChatMessage;

if chatMessage:IsA(Instance type) then
chatMessage:Clone(); chatMessage.Parent = ParentLocation;
end

You could run it in a pcall but thats not really necessary

1 Like

That didn’t work sadly, maybe it is an engine issue? Anything else I clone works, its just that specific message template wont clone

Edit: I tried remaking the message template and it still didn’t work

ChatMessage is a frame, correct?

Yes, chatMessage is a frame. Also when I cloned it and put it in to workspace, it DOES have all it’s children meaning the script just can’t see the children.

Where are you replicating it from?

Not really sure what you mean by that, but here is the entire setup:

image

ClientChatScript is the localscript that has the code that is the issue.

Edit: Heres the chatMessage children if you want to know what is inside it too
image

Honestly from what I can understand by testing its problems with studio, classes are not registering under parents which is causing errors in the code.

1 Like

By the way, this isn’t a problem just in studio. It also is an issue on the client

WAIT A MINUTE WHAT IS THIS

image

I know voice chat is coming but I didn’t think it was already starting to be put into releases and stuff

When you run studio test, you are testing on the client. When you test with “Run” you are testing on the server. By the looks of it roblox is dealing with some issues that are occurring across the fourms.

1 Like

This is a super long thread so I’m not going to read it. Here is the problem with the code in the topic:

  • You are trying to use the . operator to index something named “Name”. The . operator always looks for properties first then children.
  • This means that chatMessage.Author.Name.Badge.Visible = true is trying to do the same thing as "Author".Badge.Visible = true.
  • To solve this, either change the name of the Frame named “Name” or use FindFirstChild (chatMessage.Author:FindFirstChild("Name").Badge.Visible = true).
  • Note that your children are being cloned: The error occurs because Badge is nil (the . operator couldn’t find a property called Badge of string “Author”). This means that the frame Author was cloned with its parent.

Random Tip For #help-and-feedback:scripting-support Usage:

  • If you find out new relevant info to your problem, I’d recommend updating your topic. It makes it easier for people to help you (I have no idea if you did this or not because I didn’t read the thread anyways :smile:).
1 Like

That was so simple… thank you so much.

Thanks everyone here lol this took like 5 hours

Oops, I did not see that. ;-;
Good luck on your custom chat system.

1 Like