Can't clone objects. Always come out as nil

Change the argument name of the function to something different than the bait variable

I dont get why its nil though because its parent gets used and works in other things?

image

What I mean is basically, bait is a variable correct? And in the function, the argument is also bait, so it’s confusing the function.
image
image

Ok I changed it and it still doesn’t work.
image

image

Nvm I confused myself, remove the argument of bait in local baitUi = CreateBaitUI(bait) and make sure the function isn’t above the bait variable.

I figured maybe the fact that it’s trying to parent it to the argument isn’t parenting to the original variable. Maybe remove the argument and parent it directly to the original variable.

Not entirely sure what you meant so ive just guessed you meant like this?:

image

image

Tried it, it still doesnt work :frowning_face:

What does CreateBait(plr) return the exact folder or a table?

That creates the part that is placed into the folder. The returned value is the part instance

image

Maybe check what the parent of that object is

I printed its parents name and it is the folder which is what it should be

Are there any errors and have you remembered to Adornee and disable the Enabled bool?

Yep all of that was done and i still get this error

image

which is on this line where the baitUi is meant to be used for a tween

If I’m going to be completely honest, I have no idea what’s the bug :confused:

I’ve re-read it multiple times there are no errors in mistyping a variable or something so idk whats wrong :frowning:

This is the line causing the issue, you can’t pass instances from server to client through remotes if they aren’t already replicated to them, it will be nil.

If you want to follow good practice, all UI/visual effects should be coded on the client, the server should only handle the data related to them.

That isn’t true, it is possible to pass instances through remotes, I’ve tested it to be sure and it was.

Would an object value that stores the bait when its created work?

Corrected the reply above, the issue is replication, the instance must be already replicated to the client for it to not be nil when the server sends it to them. For example, sending workspace works because the client always has a copy of the workspace, but sending Instance.new("Part") won’t work because it’s not replicated to the client.

Also sending Instance.new("Part", workspace) doesn’t work either because the object must be replicated before the remote reaches the client, so that may be related to the issue. Basically, you must create the object, wait a bit(like one second, to account for laggy players), then fire the remote to the client.

Alright that is true, if its not replicated it won’t be detected by the client, I agree.

1 Like

How would i replicate it to the client?