I’m working on a jumpscare system similar to “The Mimic” using TweenService for the transition to the NPC’s CameraPart.
What is the Problem?
The problem is that since the NPC sometimes moves when triggering its jumpscare (unfortunately, I can’t change that), the camera while doing the Tween to CameraPart.CFrame doesn’t update the CameraPart’s CFrame correctly, which makes it go to the position that the script knew before updating.
What do I want to do?
I’d like to know if there’s a way to update the TweenService to a CameraPart.CFrame when the CameraPart moves.
System examples
In DTI (Dress To Impress), when the player goes to do their makeup or change their hair, the camera does a kind of TweenService that updates if the head position changes like this:
As you can see in the video, when the player’s head (which in my case would be the CameraPart) changes position or CFrame, TweenService seems to detect it and immediately moves to the new position of the head (CameraPart).
My Jumpscare System (Simple LocalScript):
ScareEvent.OnClientEvent:Connect(function(ScareConfigurations)
IsScare = true
ScareConfigurations.ScareSound:Play()
Camera.CameraType = Enum.CameraType.Scriptable
if ScareConfigurations.VignetteScare == true then
TweenService:Create(ScareVignette, TweenInfo.new(3, Enum.EasingStyle.Quart), {ImageTransparency = 0}):Play()
TweenService:Create(Vignette, TweenInfo.new(3, Enum.EasingStyle.Quart), {ImageTransparency = 0}):Play()
end
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
local StrongCamera = ScareConfigurations.CameraMovement
if not ScareConfigurations.PlayerScare then
local TweenCamera = TweenService:Create(Camera, TweenInfo.new(0.3), {CFrame = ScareConfigurations.ScareCamera.CFrame})
TweenCamera:Play()
TweenCamera.Completed:Wait()
end
task.wait(0.5)
game:GetService("RunService").RenderStepped:Connect(function()
if IsScare then
Camera.CameraType = Enum.CameraType.Scriptable
if ScareConfigurations.PlayerScare then
Camera.CFrame = game.Players.LocalPlayer.Character:FindFirstChild("Head").CFrame
else
Camera.CameraType = Enum.CameraType.Scriptable
local randomRotation = CFrame.Angles(
math.rad(math.random(-StrongCamera, StrongCamera) / 4),
math.rad(math.random(-StrongCamera, StrongCamera) / 4),
math.rad(math.random(-StrongCamera, StrongCamera) / 4)
)
Camera.CFrame = ScareConfigurations.ScareCamera.CFrame * randomRotation
end
end
end)
task.wait(ScareConfigurations.ScareTime - 0.5)
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Chat, true)
ScareFrame.Visible = true
if ScareConfigurations.StopSoundFinal == true then
ScareConfigurations.ScareSound:Stop()
end
if ScareConfigurations.VignetteScare == true then
TweenService:Create(ScareVignette, TweenInfo.new(3, Enum.EasingStyle.Quart), {ImageTransparency = 1}):Play()
TweenService:Create(Vignette, TweenInfo.new(3, Enum.EasingStyle.Quart), {ImageTransparency = 1}):Play()
end
TweenService:Create(Camera, TweenInfo.new(3, Enum.EasingStyle.Quart), {FieldOfView = OriginFieldOfView}):Play()
IsScare = false
Camera.CameraType = Enum.CameraType.Custom
end)
I would like you to help me with this system please. I really appreciate your responses. Thanks.