Hello,
So I have been making a game, and I have got to a phase, where the camera's CFrame is the CFrame of a part called CamPart2. You press a button, and the camera goes back to Custom and the subject is Player.Character .
That bit works fine, but the bit I am stuck on now is how do I make the camera go back to scriptable and the CFrame of the camera be CamPart2.CFrameafter player has died and respawned.
How would I approach this?
The script to make it go back to normal after pressing a button is as follows:
local players = game:GetService("Players")
local player = players.LocalPlayer
local button = script.Parent
local Camera = game.Workspace.CurrentCamera
button.MouseButton1Click:Connect(function()
local randomNumber = math.random(3)
local randomPart = game.Workspace:FindFirstChild("Spawn"..randomNumber)
local humanoidRootPart = player.Character.HumanoidRootPart
humanoidRootPart.CFrame = CFrame.new(randomPart.Position.X, randomPart.Position.Y + 5, randomPart.Position.Z)
end)
button.MouseButton1Click:Connect(function()
Camera.CameraType = 'Custom'
Camera.CameraSubject = player.Character
end)
I tried using the Humanoid.Died function but that didn't work, I'm not sure if I did it wrong or something, but it just didn't
I would think the code would go something like this
-- if the player has died,
-- set the camera to 'Scriptable'
--set the camera.CFrame = CamPart2.CFrame
How can I make another script that would run after a player dies, the camera CFrame is set back to CamPart.CFrame .
Thanks, Tony V

3 comments
I had to put a local script in "StarterCharacterScripts" and I did have to use the Humanoid.Died
Why do you have 2 'MouseButton1Click` events? You should try using CharacterAdded() since it works on respawn instead of the Died event.
but would that not also work when they join the game too? I don't want that to happen