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

What can be wrong in my code? to not change the camera view to the part?

Asked by 6 years ago
Edited 6 years ago

I need when he equip the tool and press right click it switch camera view but its not working...the local script is in the tool itself

Whats is happening?

https://gyazo.com/b2f4697893d416f5ba97110afb03a8d3

01local Tool = script.Parent
02local camera = workspace.CurrentCamera -- the current camera view
03local aim = script.Parent.AimCameraView -- the part I want the camera view to go to
04local cameraview = workspace.CameraView -- the camera in the workspace
05 
06Tool.Equipped:connect(function(Mouse)
07    Mouse.Button2Down:connect(function()
08 
09        cameraview.CameraType = Enum.CameraType.Custom
10        cameraview.CFrame = aim.CFrame
11 
12            if camera.CFrame == aim.CFrame then
13                print("The Camera is in the aim view")
14            end
15 
16    end)
17end)
0
CFrame.new() ? User#17685 0 — 6y

1 answer

Log in to vote
0
Answered by
juel90 26
6 years ago

Your setting the CFrame instead of the CameraSubject and you are also using the wrong camera try this code instead.

01local Tool = script.Parent
02local camera = workspace.CurrentCamera -- the current camera view
03local aim = script.Parent.AimCameraView -- the part I want the camera view to go to
04 
05Tool.Equipped:connect(function(Mouse)
06        Mouse.Button2Down:connect(function()
07            camera.CameraType = Enum.CameraType.Custom
08            camera.CameraSubject = aim
09                if camera.CameraSubject == aim then
10                    print("The Camera is in the aim view")
11                end
12     end)
13end)
0
The code is indenting weirdly for some reason :/ juel90 26 — 6y
Ad

Answer this question