-
What do you want to achieve?
I want to make the camera so that the animation plays and when it ends the camera goes back towards the player -
What is the issue? Include screenshots / videos if possible!
The problem is the camera is either the camera animation plays but my camera switches instantly or the players camera gets stuck to the camera rig part. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I used a while loop with a Boolean but the loop will continuously run forever. If I tried changing the Boolean in the loop it buffers and the camera is stuck to one frame. I tried to make it so the while loop breaks when it stops the animation but same problem. I tried using a repeat until loop same problem. I also tried to duplicate the the camera rig so I can destroy it but didn’t know how I would destroy it even if I tried it didnt work.
I put this in a local script under StarterCharacterScripts
local CamA = script.Parent.TakeDownCam
local UserA = script.Parent.TakeDownYou
local EnemyA = script.Parent.TakeDownEnemy
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character
local UIS = game:GetService("UserInputService")
local Enemy = workspace.Opps
local CamRigAnimator = workspace.Camera_Rig.Humanoid:WaitForChild("Animator")
local CamRigHum = CamRigAnimator.Parent
local Camera = workspace.Camera
local IsPlaying = false
UIS.InputBegan:Connect(function(input, GPE)
if GPE then return end
if input.KeyCode == Enum.KeyCode.G then
IsPlaying = true
Enemy.Archivable = true
local OpCloned = Enemy:Clone()
OpCloned.Parent = game.Workspace
for i, v in ipairs(OpCloned:GetChildren()) do
if v:IsA("Part") then
for i, c in ipairs(Character:GetChildren()) do
if c:IsA("Part") then
v.Parent.HumanoidRootPart.CFrame = c.Parent.HumanoidRootPart.CFrame * CFrame.new(0,0,-5) * CFrame.Angles(0,math.rad(180), 0)
end
end
end
end
local CamT = CamRigAnimator:LoadAnimation(CamA)
CamT:Play()
local CamRigClone = CamRigHum.Parent.Torso:Clone()
CamRigClone.Parent = workspace
while IsPlaying do
task.wait()
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = CamRigClone.CFrame
if CamT.Ended then
IsPlaying = false
break
end
end
Camera.CameraType = Enum.CameraType.Custom
end
end)