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

Problem With Camera control?

Asked by 8 years ago
local cam=game.Workspace.CurrentCamera
local play=game.Workspace.Build.Play.Play
cam.CameraSubject=game.Workspace.Build.Play.Play
cam.CameraType="Scriptable"
cam.FieldOfView=30
cam.Focus=CFrame(play.CFrame)
play.ClickDetector.MouseClick:connect(function()
    for i=1, 55 do
        cam.Focus=CFrame(play.CFrame)
        wait(0.1)
    end
end)

I am trying to make a script where the player has no access over their camera at all. The camera focuses on a brick called Play, location inside game.Workspace.Build.Play. The brick moves around 55 times when clicked, and then deleted itself. The Character is also deleted when it loads. However when I run this script it returns this error:

Here is the Error:

11:52:44.956 - Players.Player.Backpack.CameraScript:6: attempt to call global 'CFrame' (a table value)

11:52:44.957 - Stack Begin

11:52:44.958 - Script 'Players.Player.Backpack.CameraScript', Line 6

11:52:44.959 - Stack End

I don't know what a table value is, can someone explain the problem to me please?

However, after I removed the CFrame before the (play.Frame) it does not give any errors but still does not work. Anyone help? The script Now:

local cam=game.Workspace.CurrentCamera
local play=game.Workspace.Build.Play.Play
cam.CameraSubject=game.Workspace.Build.Play.Play
cam.CameraType="Scriptable"
cam.FieldOfView=30
cam.Focus=(play.CFrame)
play.ClickDetector.MouseClick:connect(function()
    for i=1, 55 do
        cam.Focus=(play.CFrame)
        wait(0.1)
    end
end)

1 answer

Log in to vote
-1
Answered by 8 years ago

CFrames are already CFrames
Also there's no typecasting like that

You don't need to construct a new CFrame from an existing CFrame value. For that reason, you can get rid of the CFrame(...) bits. The constructor for a CFrame is also CFrame.new rather than CFrame

local cam=game.Workspace.CurrentCamera
local play=game.Workspace.Build.Play.Play
cam.CameraSubject=game.Workspace.Build.Play.Play
cam.CameraType="Scriptable"
cam.FieldOfView=30
cam.Focus=play.CFrame
play.ClickDetector.MouseClick:connect(function()
    for i=1, 55 do
        cam.Focus=play.CFrame -- I'm also convinced that this doesn't do what you want it to.
        wait(0.1)
    end
end)

0
kk I changed it but it still doesn't work Volodymyr2004 293 — 8y
0
No errors? I fixed your problem. If it's not doing what you wanted, it's because you're not doing anything except for waiting. User#6546 35 — 8y
0
I want the part to always be in the center of the camera. Volodymyr2004 293 — 8y
0
It is. You're never trying to move the focus or move the part away. User#6546 35 — 8y
Ad

Answer this question