Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 2 years ago

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!

0
It's because it has to be CFrame not Cframe silver4804 2 — 2y

1 answer

Log in to vote
0
Answered by
TGazza 1336 Moderation Voter
2 years ago

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!

0
Wow that's really helpful, many thanks for helping me! DaringToast 7 — 2y
Ad

Answer this question