Problem Cutscene Attack

Problem

So I’m currently making an attack inspired by an anime, and then I wanted to add a camera for a cutscene to it and at first it worked normally but when I used the attack a second time the camera was just still at the old position and not at the camera parts position.

Video:

Code:

(For The Client):

--||Services||--
local RS = game:GetService("ReplicatedStorage")
local SoundService = game:GetService("SoundService")
local Debris = game:GetService("Debris")
local RunService = game:GetService("RunService")

--||Other||--
local tool = script.Parent
local remote = script.Parent.Remote

--||Player||--
local plr = game:GetService("Players").LocalPlayer
local char = plr.Character

local mouse = plr:GetMouse()
local Cam = workspace.CurrentCamera

--||Values||--
local End = false

------------------------------------------------------------------------------------------------------------------

remote.OnClientEvent:Connect(function(action)
	if action == "Start" then	
		Cam.CameraType = Enum.CameraType.Scriptable
		End = false
		
		local NewCam = char.CamPart

		local maxTilt = 15 --so I can move the camera a bit when I'm in the cutscene
		RunService.RenderStepped:Connect(function()
			if not End then
				Cam.CFrame = NewCam.CFrame * CFrame.Angles(
					math.rad((((mouse.Y - mouse.ViewSizeY / 2) / mouse.ViewSizeY)) * -maxTilt),
					math.rad((((mouse.X - mouse.ViewSizeX / 2) / mouse.ViewSizeX)) * -maxTilt),
					0
				)
			end				
		end)
	elseif action == "End" then
		End = true
		Cam.CameraType = Enum.CameraType.Custom
	end
end)

(The Server side):

--Camera
	local NewCam = CamFolder.CamPart:Clone()
	NewCam.Parent = char
	
	local M6D = Instance.new("Motor6D")
	M6D.Name = "CamWeld"
	M6D.Parent = hrp
	M6D.Part0 = hrp
	M6D.Part1 = NewCam
	
	remote:FireClient(plr,"Start",NewCam)
	--Camera

and

remote:FireClient(plr,"End")

Thanks in advance and tell me if you need more info!

their are no errors in the output btw

Are you destroying the cutscene new camera which is a part and the Motor6D in the end of the cutscene?

yep I am destroying both of them at the end

Make the RenderStepped a connection and disconnect it in the end of cutscene and make sure you a destroy in the server side the part at the end too

1 Like

Thanks so much that worked perfectly!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.