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.
What is the issue?
The issue that I am experiencing is that script cannot see the CameraPart:
However, I have checked in the Roblox Studio and CameraPart exists and was not removed.
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!
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)
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.
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.