This is my first time trying to script the camera in Roblox.
I've changed the CameraType to scriptable and am currently trying to change the camera Cframe to the Cframe of a part I named "ViewBlock". But for some reason, I keep getting the error message that Cframe is not a valid member of my part.
Here is my code:
local cameraPart = workspace:WaitForChild("ViewBlock") local camera = workspace.Camera print("check1") repeat wait() until camera.CameraSubject ~= nil camera.CameraType = Enum.CameraType.Scriptable print("check 2") camera.CFrame = cameraPart.Cframe print("check 3")
And here is the output message:
16:22:33.383 check1 - Client - LocalScript:3 16:22:34.110 check 2 - Client - LocalScript:8 16:22:34.110 Cframe is not a valid member of Part "Workspace.ViewBlock" - Client - LocalScript:10 16:22:34.110 Stack Begin - Studio 16:22:34.110 Script 'Players.DaringToast.PlayerScripts.LocalScript', Line 10 - Studio - LocalScript:10 16:22:34.111 Stack End - Studio 16:22:37.959 Disconnect from ::ffff:127.0.0.1|57167 - Studio
Any help would be greatly appreciated!
Just change Line 10 from:
camera.CFrame = cameraPart.Cframe
To:
camera.CFrame = cameraPart.CFrame
The first two letters of CFrame
has to be capital and nothing like ..: Cframe, cFrame, cframe,CfRaMe, CFRAME
etc.., only CFrame
works!
In Roblox Luau and normal Lua the Capitals have to match otherwise you will get errors like this.
Reference:
https://luau-lang.org/typecheck -- Good for things like this!