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