I can't see the script when I moved it

I made a script in the workspace
And my purpose is to move the script to the camera object
So I wrote script.Parent = workspace.Camera
But I can’t see the script on the camera object when I see it in the explorer. I want to know why

2 Likes

Depends on which context you’re parenting it and which context you’re viewing it from.

3 Likes

You have to write

script.Parent = workspace.CurrentCamera

as you are trying to reference the current camera object in workspace, named “CurrentCamera”.

1 Like

You can try doing:

local camera = workspace:WaitForChild("Camera")
script.Parent = camera

Since the Script may have run before the Camera has loaded, you can use WaitForChild to ensure that it exists before you use it in your code.

1 Like