I want to make it so that when the player dies, the camera tweens back to the player. I have good experience with tweening and camera manipulation, but I believe what I’m trying to achieve is too complex for me. Any ideas? If you have done it before, that’s perfect.
If you don’t know what I mean, here’s me demonstrating how the camera goes back to the player by default:
You could just have a script inside of StarterPlayerScripts (not StarterCharacter) to check when you die, lock the camera, and then tween it to your position when you respawn.
First you need to create a Tweenservice, then add a connection to detect when the player respawns, and finally tween the players camera to the current (new) character.
This script by weakroblox35 says it all:
I would personally add more to the TweenInfo to make it more smooth (TweenInfo.new(4,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut))
Isn’t that what you wanted? Because I am confused.
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character
local Camera = workspace.CurrentCamera
local Tween = game:GetService("TweenService")
Player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:FindFirstChildOfClass("Humanoid") or Character:WaitForChild("Humanoid",25)
Humanoid.Died:Connect(function()
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CameraSubject = Character:FindFirstChild("Torso")
end)
if Camera.CameraType == Enum.CameraType.Scriptable then
Tween:Create(Camera, TweenInfo.new(4), {CFrame = Character.HumanoidRootPart.CFrame}):Play()
task.wait(4)
Camera.CameraSubject = Humanoid
Camera.CameraType = Enum.CameraType.Custom
end
end)
The script works really well. So now I have to figure out how to get the camera’s new position before the game sets it. No other action is needed. Thank you for helping!