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

local Tool = script.Parent
local camera = workspace.CurrentCamera -- the current camera view
local aim = script.Parent.AimCameraView -- the part I want the camera view to go to
local cameraview = workspace.CameraView -- the camera in the workspace

Tool.Equipped:connect(function(Mouse)
    Mouse.Button2Down:connect(function()

        cameraview.CameraType = Enum.CameraType.Custom
        cameraview.CFrame = aim.CFrame 

            if camera.CFrame == aim.CFrame then
                print("The Camera is in the aim view")
            end

    end)
end)
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.

local Tool = script.Parent
local camera = workspace.CurrentCamera -- the current camera view
local aim = script.Parent.AimCameraView -- the part I want the camera view to go to

Tool.Equipped:connect(function(Mouse)
        Mouse.Button2Down:connect(function()
            camera.CameraType = Enum.CameraType.Custom
            camera.CameraSubject = aim 
                if camera.CameraSubject == aim then
                    print("The Camera is in the aim view")
                end
     end)
end)
0
The code is indenting weirdly for some reason :/ juel90 26 — 6y
Ad

Answer this question