Script just wont detect a instance

Hello. Im having the issue with an error: “Can only tween objects in the workspace”, due to the object parent Im trying to tween apparently is set to nil. On the picture it clearly shows that Container does have a parent. Can someone help me fix this? Im stuck trying to fix this for an hour now.

Are you showing the Properties for the PlayerGui inside the Player itself, or in the stored Gui? I can’t see since you didn’t include the script.

The Gui in the player is where you should be referencing this data.

(Also it’s easier for us if you copy/paste the code here and put 3 backticks (```) before and after it so it formats properly)

1 Like

I assume it has to do with the fact that the Player or PlayerGui is still nil when it’s trying to Tween it.

Are you waiting for the Player to spawn correctly? while not Player do task.wait() end will likely fix this for you.

A player instance will already be loaded in before a LocalScript can run because they are parented to the player itself so this is likely not the issue.

Perhaps the Container’s parent has already been set to nil? This seems to most probable issue since the local script running this is not parented to the container and also since the instance is stored as a variable, which would still return an instance regardless of its parent being set to nil.

Never hurts to make sure, I have no idea where OP’s script is. + I’ve also had personal experience with LocalScripts runnning before the player is created.

This is just incorrect but fine, the player will always be loaded in whenever a local script runs unless it is parented to a service like ReplicatedStorage in which case it won’t run at all as it does not have a host player. If you meant the services that come along with it like PlayerGui then you are correct, they may not be loaded in as soon as the local script executes.

1 Like

thank you for the idea, I just did repeat wait() until game:IsLoaded() and it seemed to fix the issue (id suppose your fix works too)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.