Having Trouble trying to move a Part using a TextButton

So I am Trying to make a Script where The CameraPart Goes to a different position like for example I click a play button and the camera moves to a set position

The script I made I tried adding a MouseButton1Click and Keycode so if the player would be either on console or PC they would have to click a Button/Key on their keyboard/controller it would move the camera as well as change the menu I have but it will not work I have tried looking through the devforum, YouTube, etc.

here is the script i have

local userinputService = game:GetService('UserInputService')
local CurrentCamera = workspace.CurrentCamera
local Finish = workspace.CameraPart2
local Start = workspace.CameraPart
local Play = script.Parent

Play.MouseButton1Click:Connect(function()
	Start.Position = Finish.Position
end)

userinputService.InputBegan:Connect(function(input, processed)
	if processed then return end

	if input.KeyCode == Enum.KeyCode.ButtonA then  -- Where it says ButtonA is how to change the Keycode
		Start.Position = Finish.Position
	end
end)

userinputService.InputBegan:Connect(function(input, processed)
	if processed then return end

	if input.KeyCode == Enum.KeyCode.Space then  -- Where it says ButtonA is how to change the Keycode
		Start.Position = Finish.Position
	end
end)

This is where the Camera would Start

this is where the camera would end

What exactly does not work? Is it the key presses? If so, which key presses work and which ones do not?

the camera is not moving thats the issue

Well, what are the two CameraParts? From what I can tell, you’re just changing the position of the Start camera part to the position of the Finish camera part, but you’re not actually changing the position of the actual player camera, unless you have another script that changes the player camera to the positions of the CameraParts.

i do not have another script for this. but what can i change that will make it actually move to a set position

I would recommend actually learning how to script first.

CurrentCamera.CameraType = Enum.CameraType.Scriptable
CurrentCamera.CFrame = Start.CFrame -- or End.CFrame

Simple, just adjust the CFrame of the camera.

CurrentCamera.CameraType = Enum.CameraType.Scriptable

Play.MouseButton1Click:Connect(function()
	CurrentCamera.CFrame = CFrame.lookAt(Finish.Position, Finish.Orientation)
end)

userinputService.InputBegan:Connect(function(input, processed)
	if processed then return end

	if input.KeyCode == Enum.KeyCode.ButtonA or input.KeyCode == Enum.KeyCode.Space then  -- Where it says ButtonA is how to change the Keycode
		CurrentCamera.CFrame = CFrame.lookAt(Finish.Position, Finish.Orientation)
	end
end)

im only basic at scripting and i just recently started learning how to script

The script works but i ran to another issue where the orientation goes to the wrong set orientation

Switch to CFrame.lookAlong instead of CFrame.lookAt

now the camera is set to the button of the part but i think i can just rotate the part so it does not look like that

Edit: No it doesnt

You can simply set the CurrentCamera.CFrame to your Part.CFrame, you would just have to rotate the part to get your rotation.

that makes the script not work entirely and i did not receive an error

Come on brother, you gotta try a bit harder. Send the error and your new code over.

Dude im sorry that you have to go through this but heres the entire script

local userinputService = game:GetService('UserInputService')
local CurrentCamera = workspace.CurrentCamera
local Finish = workspace.CameraPart2
local Start = workspace.CameraPart
local Play = script.Parent

CurrentCamera.CameraType = Enum.CameraType.Scriptable

Play.MouseButton1Click:Connect(function()
	Finish.CFrame = CFrame.lookAt(Finish.Position, Finish.Orientation)
end)

userinputService.InputBegan:Connect(function(input, processed)
	if processed then return end
	
	if input.KeyCode == Enum.KeyCode.ButtonA then  -- Where it says ButtonA is how to change the Keycode
		Finish.CFrame = CFrame.lookAt(Finish.Position, Finish.Orientation)
	end
end)

userinputService.InputBegan:Connect(function(input, processed)
	if processed then return end

	if input.KeyCode == Enum.KeyCode.Space then  -- Where it says ButtonA is how to change the Keycode
		Finish.CFrame = CFrame.lookAt(Finish.Position, Finish.Orientation)
	end
end)

this is what it looks like in game

This code isn’t even changing the Camera.CFrame anymore?

Copy and paste these lines to position your camera to either the Start or Finish camera parts and get rid of your other CFrame lines:

-- to position to start
CurrentCamera.CFrame = Start.CFrame

-- to position to end
CurrentCamera.CFrame = Finish.CFrame

so setting up those lines of code to where i located will work?

userinputService.InputBegan:Connect(function(input, processed)
	if processed then return end

	if input.KeyCode == Enum.KeyCode.Space then  -- Where it says ButtonA is how to change the Keycode
		CurrentCamera.CFrame = Start.CFrame
		CurrentCamera.CFrame = Finish.CFrame
	end
end)

One of those lines, not both. Putting both of those lines in will set the CFrame to the Start, then Finish shortly after, obviously.

well i just tested it and it works i appreciate the help thank you

i Ran into a New issue and it now Gives me an error Saying LocalScript: attempt to index nil with ‘CFrame’

Edit: NVM it was streaming enabled causing an issue