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

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

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)

1 comment

0

CFrame.new() ?

1 answer

✓ Accepted answer

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)

1 comment

0

The code is indenting weirdly for some reason :/

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