Trying to make camera move to a part in my autoshop

i want the camera to move to a parts rotation and position, but it just says position is not a child of camera

local Music = game.Workspace:FindFirstChild("AutoShop"):WaitForChild("Song"):WaitForChild("Sound")
local LocalMusic = game.SoundService:WaitForChild("AutoShopMusic")
local Event = game.ReplicatedStorage:WaitForChild("AutoShopMusic")

local part = Music.Parent.Parent.Focus
local camera = game.Workspace.Camera

local cam = game

local TurnedDown = false

Event.OnClientEvent:Connect(function()
	if TurnedDown == false then
		TurnedDown = true
		Music.Volume = 0
		LocalMusic.Volume = .5
		
		camera.postiton = part.Position
		
	else
		TurnedDown = false
		Music.Volume = 0.1
		LocalMusic.Volume = 0
		
		
		
	end
end)

idk how to manipulate the camera
(specifically, how do i make it transition to the part, not jsut teleport there)

Use a LocalScript to move the camera to a part, as using a server script won’t work. Here’s an oversimplified example of how you can do it:

local Camera = game.Workspace.CurrentCamera
local Part = game.Workspace.Part

Camera.CameraType = Enum.CameraType.Scriptable
Camera.Focus = Part.CFrame

Also, to make it transition to the part, try learning about TweenService, and use it to transfer the camera to the part.

Just swap these with CFrame

camera.CFrame = part.CFrame

its already a local script, so ill try what the other guy said

it now rotates my camera to match the parts rotation, i want the camera to move to the part tho

This what you mean?

local ts = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine)

task.wait(4)

local camera = game.Workspace.Camera
while camera.CameraType ~= Enum.CameraType.Scriptable do
	camera.CameraType = Enum.CameraType.Scriptable
end


ts:Create(camera, tweenInfo, {CFrame = workspace.Part.CFrame}):Play()

this just makes the camera stop following the player when i start the game…
heres the code i have so far:

local Music = game.Workspace:FindFirstChild("AutoShop"):WaitForChild("Song"):WaitForChild("Sound")
local LocalMusic = game.SoundService:WaitForChild("AutoShopMusic")
local Event = game.ReplicatedStorage:WaitForChild("AutoShopMusic")

local part = Music.Parent.Parent.Focus
local camera = game.Workspace.Camera

local cam = game

local TurnedDown = false

local ts = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine)

task.wait(4)

local camera = game.Workspace.Camera
while camera.CameraType ~= Enum.CameraType.Scriptable do
	camera.CameraType = Enum.CameraType.Scriptable
end


local CamTween = ts:Create(camera, tweenInfo, {CFrame = part})

Event.OnClientEvent:Connect(function()
	if TurnedDown == false then
		TurnedDown = true
		Music.Volume = 0
		LocalMusic.Volume = .5
		
		CamTween:Play()
		
	else
		TurnedDown = false
		Music.Volume = 0.1
		LocalMusic.Volume = 0
		
		
		
	end
end)
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine)

local Music = game.Workspace:FindFirstChild("AutoShop"):WaitForChild("Song"):WaitForChild("Sound")
local LocalMusic = game.SoundService:WaitForChild("AutoShopMusic")
local Event = game.ReplicatedStorage:WaitForChild("AutoShopMusic")

local part = Music.Parent.Parent.Focus
local camera = game.Workspace.Camera

local cam = game

local TurnedDown = false

function tweenCamera(part)
	while camera.CameraType ~= Enum.CameraType.Scriptable do
		camera.CameraType = Enum.CameraType.Scriptable
	end
	
	ts:Create(camera, tweenInfo, {CFrame = part.CFrame}):Play()
end

Event.OnClientEvent:Connect(function()
	if TurnedDown == false then
		TurnedDown = true
		Music.Volume = 0
		LocalMusic.Volume = .5

		tweenCamera(part)
	else
		TurnedDown = false
		Music.Volume = 0.1
		LocalMusic.Volume = 0
	end
end)

does the same exact thing as before…

Can you see any errors in the console by any chance?

TweenService:Create property named ‘CFrame’ cannot be tweened due to type mismatch (property is a ‘CoordinateFrame’, but given type is ‘Instance’)

Is this a part?

Try to add this:

Event.OnClientEvent:Connect(function()
	if TurnedDown == false then
		TurnedDown = true
		Music.Volume = 0
		LocalMusic.Volume = .5

		if not part:IsA("BasePart") then
			warn("Part isn't a basepart")
		end
	else
		TurnedDown = false
		Music.Volume = 0.1
		LocalMusic.Volume = 0
	end
end)

focus is a part yes, its a part in a model.
Should i reference it diffrenty?

Oops, looks like TweenService cut off

Try this:

local ts = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine)

local Music = game.Workspace:FindFirstChild("AutoShop"):WaitForChild("Song"):WaitForChild("Sound")
local LocalMusic = game.SoundService:WaitForChild("AutoShopMusic")
local Event = game.ReplicatedStorage:WaitForChild("AutoShopMusic")

local part = Music.Parent.Parent.Focus
local camera = game.Workspace.Camera

local cam = game

local TurnedDown = false

function tweenCamera(part)
	while camera.CameraType ~= Enum.CameraType.Scriptable do
		camera.CameraType = Enum.CameraType.Scriptable
	end
	
	ts:Create(camera, tweenInfo, {CFrame = part.CFrame}):Play()
end

Event.OnClientEvent:Connect(function()
	if TurnedDown == false then
		TurnedDown = true
		Music.Volume = 0
		LocalMusic.Volume = .5

		tweenCamera(part)
	else
		TurnedDown = false
		Music.Volume = 0.1
		LocalMusic.Volume = 0
	end
end)

no variables called “ts” or “tweeninfo”
Can you add those? idk what they should be

Have you used the code I’ve given you? Cause it seems like you forgot to put .CFrame

Try the latest codeblock I posted.

that works, i didnt copy the whole thing lol
How would i make the camera do the same thing but go back to the player when another event is fired?

If you want to smoothly tween it back to the player’s previous cameras position, then you’d save the previous CFrame in a variable.

Example:

local prevCamCFrame = nil
function tweenCamera(part, toPlr)
	if toPlr then
		local tween = ts:Create(camera, tweenInfo, {CFrame = prevCamCFrame})
		tween:Play()
		tween.Completed:Wait()
		camera.CameraType = Enum.CameraType.Custom
	else
		prevCamCFrame = camera.CFrame
		while camera.CameraType ~= Enum.CameraType.Scriptable do
			camera.CameraType = Enum.CameraType.Scriptable
		end
		ts:Create(camera, tweenInfo, {CFrame = part.CFrame}):Play()
	end
end

And then you’d just tween it back when the second argument is true

So if you’d want the camera to go to the player then you just set the 2nd argument to true else if it goes to a part you leave it empty or set it to false

tweenCamera(part, false) --Makes it go to the part
tweenCamera(part, true) --Makes it go back to the player