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

Why is my camera not setting the Focus or the CFrame?[SOLVED]

I have tried to fix this before I posted it but basically I want to have it to where it focuses on a certain part and be a certain distance away. But it isn't doing a single thing other than outputting "Focus and Coord set!". No errors what so ever. Here is the code:

-- Time for a huge script!

-- Wait For Crap --
while game.Workspace.CurrentCamera == nil do wait() end

local cam = game.Workspace.CurrentCamera

-- Libraries/ModuleScripts --
--local camera = require(script.CameraPlus)
--local Module3D = require(script.Module3D)

cam.CameraSubject = nil

cam.CameraType = "Scriptable"

-- Putting the camera at a certain CFrame coordinate and focus. --
cam.CoordinateFrame=game.Workspace:WaitForChild("ShopCamera").CFrame
cam.Focus = game.Workspace:WaitForChild("Part").CFrame
print("Focus and Coord set!")

Thank you so much for helping! I very much appreciate it!

1 answer

✓ Accepted answer

You're trying to run the script before the client has loaded, put a wait() on the first line

Also:

Scriptable camera is different from regular camera types, you can only set the coordinate frame with scriptable, but can set the focus within it:

cam.CoordinateFrame = CFrame.new(CoordinateFrame, Focus) -- You can only set CoordinateFrame, but lookvector plays a role. 

So to put it in use for you:

cam.CoordinateFrame=CFrame.new(game.Workspace:WaitForChild("ShopCamera").Position, game.Workspace:WaitForChild("Part").Position)

9 comments

0

The second block of code is cut off, but if you copy it to your clipboard and paste it in studio you will be able to see the entire thing.

0

Still isn't working, I found that the camera's CameraType isn't even getting set... Not anything.

0

This is a LocalScript within a Local location, correct?

0

StarterGui in ShopGUI.

0

Alright, is it a LocalScript?

0

Yes

0

Updated my answer.

0

Hey! It worked! Thanks man

0

No problem!

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