Script doesn't see the part or doesn't work at all

  1. What do you want to achieve?
    Hello! I’m working on a project and I have encountered a problem with Camera’s CFrame and this script.

  2. What is the issue?
    The issue that I am experiencing is that script cannot see the CameraPart:
    image
    However, I have checked in the Roblox Studio and CameraPart exists and was not removed.

  3. What solutions have you tried so far?
    I have tried many solutions including devforum, however, I did not find any. If you could help me it would be appreciated, thanks! :slight_smile:

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

workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
workspace.CurrentCamera.CFrame = workspace:WaitForChild("CameraPart").CFrame
print("one connected")
local connection = workspace.CameraPart:GetPropertyChangedSignal("CFrame"):Connect(function()
	workspace.CurrentCamera.CFrame = workspace:WaitForChild("CameraPart").CFrame
	print("one connected")
end)

Use game.Workspace instead of Workspace.

Nope, didn’t work. “workspace” is the same thing like “game.Workspace”.

But you used Workspace, which is undefined now I think. I just tried it in my studio and it works.

Alright, I just realized that I named the part incorrectly so it could not find the part but now it still doesn’t change the camera. It prints “one connected” but camera didn’t change.

1 Like

Workspace/workspace are both defined, its only Workspace that is depecrated.

This is what I have in the output:
image
(don’t mind the rbassetid thing)

I don’t know if you’ve fix the problem yet but concerning this:

Is it not connecting to the CFrame Change of the part and not the camera?
Or it didn't change the CFrame of the camera at all, in this line?

Yep, it didn’t change the CFrame of the camera at all in this line:
workspace.CurrentCamera.CFrame = workspace:WaitForChild("CameraPart").CFrame

local Run = game:GetService("RunService")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Camera = workspace.CurrentCamera

local CameraPart = workspace:WaitForChild("CameraPart")

Camera.CameraType = Enum.CameraType.Scriptable

Run.RenderStepped:Connect(function()
	Camera.CFrame = CameraPart.CFrame
end)

Physics related properties don’t fire the .Changed event of instances. Similarly, RBXScriptSignal objects created via the instance method :GetPropertyChangedSignal() do not fire for physics related properties.

1 Like

Yep! That worked, I’ll note this down for future and thank you so much. :slight_smile:

1 Like