Well, my problem is that when I move the camera with tweenService and return it, it returns directly to the head position and not to the original position that the camera had and I really don’t know how to fix it. When it “returns” the position is on line 24 to 28
local Workspace = game:GetService("Workspace")
local TweenService = game:GetService("TweenService")
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character
local CurrentCamera = Workspace.CurrentCamera
local isOpen = false
script.Parent.MouseButton1Down:Connect(function()
isOpen = not isOpen
if isOpen then
CurrentCamera.CameraType = Enum.CameraType.Scriptable
local tweenInfo = TweenInfo.new(5, Enum.EasingStyle.Quad, Enum.EasingDirection.In, 0)
local CameraStartPart = {CFrame = Workspace:WaitForChild("CameraStart").CFrame}
local CameraTweenStart = TweenService:Create(CurrentCamera, tweenInfo, CameraStartPart)
CameraTweenStart:Play()
script.Parent.Text = "Abierto"
else
CurrentCamera.CameraType = Enum.CameraType.Scriptable
local tweenInfo = TweenInfo.new(5, Enum.EasingStyle.Quad, Enum.EasingDirection.In, 0)
local CameraStartPart = {CFrame = Character:WaitForChild("Head").CFrame}
local CameraTweenStart = TweenService:Create(CurrentCamera, tweenInfo, CameraStartPart)
CameraTweenStart:Play()
CameraTweenStart.Completed:Wait()
CurrentCamera.CameraType = Enum.CameraType.Custom
script.Parent.Text = "Cerrado"
end
end)
Yes, I already have an idea but it gave me an error “Unable to cast to Dictionary” In the part of: local CameraTweenStart = TweenService:Create(CurrentCamera, tweenInfo, CamCFrameFInish)
The part that connects the two is:
local CurrentCamera = Workspace.CurrentCamera
local CamCFrameFInish = CurrentCamera.CFrame
local CameraTweenStart = TweenService:Create(CurrentCamera, tweenInfo, CamCFrameFInish)
I already solved this but now it does not move to the original position but it goes elsewhere
local Workspace = game:GetService("Workspace")
local TweenService = game:GetService("TweenService")
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character
local CurrentCamera = Workspace.CurrentCamera
local CamCFrameFInish = {CFrame = CurrentCamera.CFrame}
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.In, 0)
local isOpen = false
script.Parent.MouseButton1Down:Connect(function()
isOpen = not isOpen
if isOpen then
CurrentCamera.CameraType = Enum.CameraType.Scriptable
local CameraStartPart = {CFrame = Workspace:WaitForChild("CameraStart").CFrame}
local CameraTweenStart = TweenService:Create(CurrentCamera, tweenInfo, CameraStartPart)
CameraTweenStart:Play()
script.Parent.Text = "Abierto"
else
CurrentCamera.CameraType = Enum.CameraType.Scriptable
local CameraTweenStart = TweenService:Create(CurrentCamera, tweenInfo, CamCFrameFInish)
CameraTweenStart:Play()
CameraTweenStart.Completed:Wait()
CurrentCamera.CameraType = Enum.CameraType.Custom
script.Parent.Text = "Cerrado"
end
end)
I changed it up so after the tweening of the camera it goes back to the player. This is the script:
local Workspace = game:GetService(“Workspace”)
local TweenService = game:GetService(“TweenService”)
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character
local CurrentCamera = Workspace.CurrentCamera
local CamCFrameFInish = {CFrame = CurrentCamera.CFrame}
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.In, 0)
local isOpen = false
script.Parent.MouseButton1Down:Connect(function()
isOpen = not isOpen
if isOpen then
CurrentCamera.CameraType = Enum.CameraType.Scriptable
local CameraStartPart = {CFrame = Workspace:WaitForChild("CameraStart").CFrame}
local CameraTweenStart = TweenService:Create(CurrentCamera, tweenInfo, CameraStartPart)
CameraTweenStart:Play()
script.Parent.Text = "Abierto"
else
CurrentCamera.CameraType = Enum.CameraType.Scriptable
local CameraTweenStart = TweenService:Create(CurrentCamera, tweenInfo, CamCFrameFInish)
CameraTweenStart:Play()
CameraTweenStart.Completed:Wait()
CurrentCamera.CameraType = Enum.CameraType.Custom
CurrentCamera.CameraSubject = Character.Humanoid
CurrentCamera.CameraType = "Custom"
CurrentCamera.CFrame = Character.Head.CFrame
script.Parent.Text = "Cerrado"
end
end)