Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Send help!! Cframe is not a valid member of Part?

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!

1 comment

0

It's because it has to be CFrame not Cframe

1 answer

✓ Accepted answer

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/syntax

https://luau-lang.org/typecheck -- Good for things like this!

1 comment

0

Wow that's really helpful, many thanks for helping me!

This discussion is preserved as it was. New answers, comments, and votes are closed.