Hi!
So basically, I was wondering how I would be able to use :destroy() on the camera, and then make a new one (locally) once the player's humanoid health is at 0.
Any help?
This is a LocalScript:
local button = script.Parent local cam = game.Workspace.CurrentCamera shared.camRotate = false button.MouseButton1Down:Connect(function() wait(4.5) cam.CameraSubject = game.Players.LocalPlayer.Character.Humanoid cam.CameraType = "Custom" shared.camRotate = true game.StarterGui.LocalScript:Destroy() game.Workspace.CamPart:Destroy() end) if game.Players.LocalPlayer.Character.Humanoid.Health == 0 then cam:Destroy() wait(6) local x = Instance.new("Camera") x.Name = "CurrentCamera" x.CameraSubject = game.Players.LocalPlayer.Character.Humanoid x.CameraType = "Custom" end
Heres the script which adjusts the camera on spawn:
local Camera = game.Workspace.CurrentCamera local Player = game.Players.LocalPlayer repeat wait() until Player.Character Camera.CameraType = "Scriptable" Camera.CFrame = game.Workspace.CamPart.CFrame script.Parent.Enabled = true
Is there any way to reset the camera to default after a player clicks a button or with wait()?
It's not recommended to make a new camera. You should reset the Camera to its default property. Making a new camera doesn't help you with this, and the resetting camera solution is much easier. I'm also noticing that you're trying to change the CameraType with cam.CameraType = "Custom"
, this could be an error. Instead, try cam.CameraType = Enum.CameraType.Custom
.
Change the CameraType to custom and CameraSubject back to the humanoid, like so:
local Players = game:GetService('Players') local Player = Players.LocalPlayer local Cam = workspace.CurrentCamera local Character = Player.Character or Player.CharacterAdded:Wait() Cam.CameraType = Enum.CameraType.Custom Cam.CameraSubject = Character:WaitForChild('Humanoid')