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

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

Asked by
Gamenew09 180
10 years ago

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

Log in to vote
2
Answered by
Sublimus 992 Moderation Voter
10 years ago

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)
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. Sublimus 992 — 10y
0
Still isn't working, I found that the camera's CameraType isn't even getting set... Not anything. Gamenew09 180 — 10y
0
This is a LocalScript within a Local location, correct? Sublimus 992 — 10y
0
StarterGui in ShopGUI. Gamenew09 180 — 10y
View all comments (5 more)
0
Alright, is it a LocalScript? Sublimus 992 — 10y
0
Yes Gamenew09 180 — 10y
0
Updated my answer. Sublimus 992 — 10y
0
Hey! It worked! Thanks man Gamenew09 180 — 10y
0
No problem! Sublimus 992 — 10y
Ad

Answer this question