I am trying to tween the current camera so that it moves behind the player but it is not working. I can’t remember how to use tween that well as I am a bit rusty at the moment. Could I get some help fixing this?
local TweenService = game:GetService("TweenService")
local goals, tweenInfo, tweens = {}, {}, {} --Used for tween service.
-------------------------------------------:
--Reset the frame:
--Set camera to face the same direction as player
goals[1] = CFrame.lookAt(game.Workspace.CurrentCamera.CFrame.Position, game.Workspace.CurrentCamera.CFrame.Position + game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.LookVector)
tweenInfo[1] = TweenInfo.new(
0.5, --tween length
Enum.EasingStyle.Quint, --easing Style
Enum.EasingDirection.Out --easing Direction
)
tweens[1] = TweenService:Create(game.Workspace.CurrentCamera, tweenInfo[1], goals[1])
game.Workspace.CurrentCamera.CameraType = "Scriptable"
tweens[1]:Play()
tweens[1].Completed:Wait()
goals[1]
at line 7 is wrong.
You have to structure it as a dictionary with the keys being the properties (in this case the CFrame) and their value (in this case whatever you put in goals[1])
goals[1] = {
CFrame = CFrame.lookAt(game.Workspace.CurrentCamera.CFrame.Position, game.Workspace.CurrentCamera.CFrame.Position + game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.LookVector)
}
I keep getting this error even after fixing it
--Set camera to face the same direction as player
goals[1] = {
CFrame.lookAt(game.Workspace.CurrentCamera.CFrame.Position, game.Workspace.CurrentCamera.CFrame.Position + game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.LookVector)
}
tweenInfo[1] = TweenInfo.new(
0.5, --tween length
Enum.EasingStyle.Quint, --easing Style
Enum.EasingDirection.Out --easing Direction
)
tweens[1] = TweenService:Create(game.Workspace.CurrentCamera, tweenInfo[1], goals[1])
game.Workspace.CurrentCamera.CameraType = "Scriptable"
… You forgot to set the key. It has to be structured like the code in my previous answer, just copy/paste it
local TweenService = game:GetService("TweenService")
local goals, tweenInfo, tweens = {}, {}, {} --Used for tween service.
-------------------------------------------:
--Reset the frame:
--Set camera to face the same direction as player
goals[1] = {}
goals[1].CFrame = CFrame.lookAt(game.Workspace.CurrentCamera.CFrame.Position, game.Workspace.CurrentCamera.CFrame.Position + game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.LookVector)
tweenInfo[1] = TweenInfo.new(
0.5, --tween length
Enum.EasingStyle.Quint, --easing Style
Enum.EasingDirection.Out --easing Direction
)
tweens[1] = TweenService:Create(game.Workspace.CurrentCamera, tweenInfo[1], goals[1])
game.Workspace.CurrentCamera.CameraType = "Scriptable"
tweens[1]:Play()
tweens[1].Completed:Wait()