I’m working on a respawn menu that upon player death, sets their camera’s cframe to a part to look at a scene. Once they hit the respawn button, their camera should then reset to the player. Unfortunately this works precisely once, and then afterwards it sets the camera’s position to the location where the player last died.
Here is my script (inside of a ScreenGui inside of StarterGui)
local WeaponSelectFrame = script.Parent.WeaponSelectFrame
local RespawnScreenFrame = script.Parent.RespawnScreenFrame
local players = game:GetService("Players")
local player = players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local respawnButton = RespawnScreenFrame.RespawnButton
local weaponSelectButton = RespawnScreenFrame.WeaponSelectButton
function setCamera()
game.Workspace.Camera.CameraType = Enum.CameraType.Scriptable
game.Workspace.CurrentCamera.CFrame = game.Workspace:WaitForChild("CameraPart").CFrame
print("setting player's camera")
RespawnScreenFrame.Visible = true
end
setCamera()
respawnButton.Activated:Connect(function()
RespawnScreenFrame.Visible = false
WeaponSelectFrame.Visible = false
print("resetting camera")
workspace.Camera.CameraType = Enum.CameraType.Custom
end)
hum.died:Connect(function()
setCamera()
end)