Hey dev’s. I am making a little nightmares inspired game on roblox and i want boss fights. but i don’t know how to change the camera’s CFrame to the default one. Please Help.
The LocalScript:
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local function GameCamera()
camera.CameraSubject = player.Character.HumanoidRootPart
camera.FieldOfView = 70
end
local function BossCamera()
camera.CameraSubject = player.Character.Humanoid
camera.FieldOfView = 70
end
game:GetService(“RunService”).Stepped:Connect(function()
if camera.CameraType == Enum.CameraType.Attach then
GameCamera()
camera.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position) * CFrame.new(0,3,18)
else
BossCamera()
– This is where the default camera CFrame will be. [I already tested it another way]
end
end)
When the camera type is Custom, the camera is stuck in the air facing the ground.
This probably isn’t the best way but if at the beginning of the script the CFrame is normal you can do something to save it, I’ve done something similar but with size for a blinking system since different characters have different size eyes.
oh yeah im not sending the cameratype in the local function.
It’s because if i want to make a cutscene, i make the cameratype scriptable and then attach when the cutscene is done. or if its a boss fight cutscene i make it custom instead of attach.
You may have typed something wrong, it should work. Try looking for errors it gives
Also try this:
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local cameraOrigin = camera.CFrame
player.CharacterAdded:Wait()
player.Character:WaitForChild(“HumanoidRootPart”)
local function GameCamera()
camera.CameraSubject = player.Character.HumanoidRootPart
camera.FieldOfView = 70
end
local function BossCamera()
camera.CameraSubject = player.Character.Humanoid
camera.FieldOfView = 70
end
game:GetService(“RunService”).Stepped:Connect(function()
if camera.CameraType == Enum.CameraType.Attach then
GameCamera()
camera.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position) * CFrame.new(0,3,18)
else
BossCamera()
camera.CFrame = cameraOrigin
end
end)