How to make a Piggy-like jumpscare?

I want to achieve a jumpscare camera like the one we see in Piggy.

I made a simple camera script that I thought would do the trick by just fixing the camera in first person while facing a certain character. The thing is, the camera is too close to the character that I want to focus on.

Whenever Piggy attacks you it is 1 or 2 studs away from your character. However, the jumpscare camera makes it seem like you are a little farther, without your own character in the way of its view. How would I approach making this?

If you are curious of what my current code looks like, look below.

Server
triggerJumpscare:FireClient(target,playerRoot.Position)
Client
triggerJumpscare.OnClientEvent:Connect(function(position)
	camera.CameraType = Enum.CameraType.Scriptable

	local head = localPlayer.Character.Head
	head.Anchored = true

-- faces camera torwards character in first-person
	camera.CFrame =  CFrame.new(head.Position,position)
		
	wait(2)
	camera.CameraType = Enum.CameraType.Custom	
end)

5 Likes

You can pay someone to do this. There are multiple tutorials on how to do this on YouTube.

3 Likes

If there were tutorials on how to do this on youtube, I wouldn’t have made this thread. I also wouldn’t have made this thread if I wanted someone to do it for me.

I am asking how I can improve my code to achieve the effect you would see in Piggy. Please, if you do not have a solution that would help me find new ways to tackle this problem, try not to pass “pay someone to do it for you/just find tutorials on youtube” as a solution. Thank you.

7 Likes

You can probably share the script, then people will help you.

I edited my post to have the code that I made. But, I am looking for how other people approached this in their games, I’m not looking for someone to troubleshoot my code itself.

I hope you understand.

Just make your own character transparent and make the camera be a more comfortable distance away. You can also try tweaking Camera properties like FOV.

6 Likes

Don’t position the camera based on the player’s position. Position it based on Piggy’s position. Anchor Piggy’s HumanoidRootPart or something, then position the camera like this.

camera.CFrame = piggy.Head.CFrame:ToWorldSpace(CFrame.new(Vector3.new(0, 0, -5))) --play around with the Vector3, like make some numbers negative and whatnot until you get the result you want
--this is an example, you have to pass over piggy in the remote or find another way to access piggy

If you want to get cool, you can tween the CFrame of the camera.

3 Likes

I tried your snippet out with my own variables in place, but it doesn’t seem to be facing the character that I want to focus on.

What should I do?

1 Like

Make sure you’re sending the right character. In this case, you want to send over piggy from the RmeoteEvent, or find another way to access piggy from the client.

The code for a jump-scare goes something like this. Client code anyway, you can handle the server sided stuff on your own.

local camera = workspace.CurrentCamera

Jumpscare.OnClientEvent:Connect(function()
    camera.CameraType = Enum.CameraType.Scriptable
    local oldCFrame = camera.CFrame

    -- you can change other properties like field of view here before you change the CFrame

    camera.CFrame = -- displacement CFrame goes here.
    -- wait some time, or however you want to handle it.

    camera.CFrame = oldCFrame
end)


This code is a guide, not an answer. This stuff is pretty simple and you should learn about camera manipulation.

I found this video on YouTube and it works really well! Here’s the link!

Roblox - FNAF Jumpscare / Animated Jumpscare - Tutorial + Model - YouTube and the model Jumpscare - Roblox

1 Like

How I make my piggy jumpscare:

  • Learn more about CFrame
  • Create a RemoteEvent on ReplicatedStorage and call it AttackEvent or something like that
  • Use humanoid.Touched beside of torso.Touched
  • Control the camera and player death effect on StarterGui

Hope this helpful

i tried to make a jumpscare like piggy before but what happened is that the NPC jumpscared me but behind the the NPC was facing At the back of the player. What is the issue?