How to MAKE JUMPSCARES in Roblox Studio!
ฝัง
- เผยแพร่เมื่อ 10 ก.พ. 2025
- How to MAKE JUMPSCARES in Roblox Studio!
🛠 This is How to MAKE JUMPSCARES in Roblox Studio! Thanks so much for watching, hope you guys have a great day! Subscribe 😎🛠
🕸️Website: rustysillyband...
😎Subscribe: www.youtube.co...
💬Discord: / discord
🌴Roblox Group: www.roblox.com...
👑Rusty Merch: www.roblox.com...
⌚Timed Chapters:
0:00 Intro
0:50 Jump Scare Box
2:31 Animation
4:25 Scripting
11:12 Testing
11:30 Outro
📝Tags:
#roblox #robloxstudio #gamedevelopment #robloxstudioscripting #robloxstudiotutorial #lua #robloxhorror #robloxhorrorgames
❓What is Roblox Studio?
🔎Roblox Studio lets you create anything and release with one click to smartphones, tablets, desktops, consoles, and virtual reality devices.
❓Who am I?
🔎I am a Roblox Studio Tutorial TH-camr that you should Subscribe to :)
if you want a sound to play:
1. go to the toolbox and find a jumpscare sound you like
2. add it under the script and name it "JumpscareSound"
3. open the Jumpscare script
4. under the long local tween line of code, add this:
local sound = script.JumpscareSound
sound:Play()
(Please tell me bro's online)
For some reason it plays if you just join the literal game
I put the code before the end is there something wrong?
Or, you can make a part have a sound in it, give it a sound, name it "Jumpscare", and insert a script with this:
local part = workspace:WaitForChild("SoundBrick") -- Change "Part" to the name of your part
local sound = part:WaitForChild("Jumpscare") -- Make sure you use the name of the sound in the part
-- Function that listens for when the player dies
local function onPlayerDeath(player)
-- Check if the character has a humanoid and is dead
local character = player.Character
if character then
local humanoid = character:FindFirstChild("Humanoid")
if humanoid and humanoid.Health == 0 then
-- Play the sound when the player dies
sound:Play()
end
end
end
-- Listen for when a player dies
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
-- Connect to the Humanoid.Died event
humanoid.Died:Connect(function()
onPlayerDeath(player)
end)
end)
end)
Script for the lazy pals:
--{SERVICES}--
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
--{VARIABLES}--
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local currentCamera = game.Workspace.CurrentCamera
local rig = game.Workspace.JumpscareBox.HorrorMonster
--{FUNCTIONS}--
local animationTrack = rig.Humanoid.Animator:LoadAnimation(script.JumpscareAnimation2):Play()
local function onDeath()
currentCamera.CameraType = Enum.CameraType.Scriptable
currentCamera.CFrame = rig.Head.CFrame + (rig.Head.CFrame.LookVector * 3)
currentCamera.CFrame = CFrame.lookAt(((rig.Head.Position + Vector3.new(0, 1, 0) + (rig.Head.CFrame.LookVector * 3)), rig.Head.Position))
local tween = TweenService:Create(currentCamera, TweenInfo.new(0.1 Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 13, true), {CFrame = currentCamera.CFrame + currentCamera.CFrame.LookVector * 0.5})
tween:Play()
task.wait(1000)
currentCamera.CameraType = Enum.CameraType.Custom
end
character.Humanoid.Died:Connect(onDeath)
Thx
@@Countrable024 np!
tysm
@Alaskaspoo Yeah it's kinda outdated I think
@Alaskaspoo idk abt that
Thank you for these kind of videos
very useful, you deserve more attraction to your channel.
my animation included moving of head and arms of monster but for some reason only the head is moving and so the jumscare looks rly bad. how do i fix this?
Thank you so much you make things so simple
It doesn't work when I touch the entity but the jumpscare will repeat every time I die tho it wont dissaper. Got any clues?
edit: now it disapper after 4 seconds but still when I Touch the entity it doesn't work and it shows either one frame of the animation or the end
Can you make a daily reward system tutorial? Btw your editing is too good. Good job rusty.
i need this for my horror game thanks! (Rate: 10/10)
Thanks bro! Helped a lot!
thanks so much! i needed this for my horror game
When I click the publish animation
it pops up but no save button?
Its literally roblox's so bad ui man
:(
thanks alot ive been trying to find a tutorial on how to make a jumpscare for a while now but how do i make it so a sound plays when the jumpscare is triggerd
Oh man, I forgot to add that to the tutorial! Sorry about that! To add a sound to the jumpscare, you can simply play it using this function:
local sound = script.Sound
sound:Play()
Just make sure you put the sound:Play() function in the onDeath function and you put a sound inside of the local script named "Sound".
Thank you so much for watching, have an amazing day!
@@rustysillyband but where should i exactly put that script im kinda confused
@@StevanBunicHi there! You should have a local script from the tutorial with a function inside of it named "onDeath". Inside of that function, you can use the code I provided and it doesn't really matter exactly where you put it in that function. Thanks for watching, have an amazing day!
@rustysillyband Can you make a tutorial cause i still dont understand how to add sound
Very good thanks man
I have a problem the animation doesn’t play and when I die again the jump scare doesn’t pop up can someone help
Make sure that everything is spelled correctly.
Make sure that there are no errors in your script.
Could you make a video on working with the players camera, and mostly on locking the players camera on a part so they cant look around?
can sum1 pls help i am not respawning but other than that the animation plays fine
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local currentCamera = game.Workspace.CurrentCamera
local rig = game.Workspace.JumpscareBox.JumpscareBot
local animationTrack = rig.Humanoid.Animator:LoadAnimation(script.JumpscareAnimation)
local function resetCameraAndRespawn()
currentCamera.CameraType = Enum.CameraType.Custom
player:LoadCharacter()
end
local function onDeath()
currentCamera.CameraType = Enum.CameraType.Scriptable
currentCamera.CFrame = rig.Head.CFrame + (rig.Head.CFrame.LookVector * 3)
currentCamera.CFrame = CFrame.lookAt(rig.Head.Position + Vector3.new(-2.1, -2.8, 6.1) + (rig.Head.CFrame.LookVector * 3), rig.Head.Position)
local tween = TweenService:Create(currentCamera, TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 13, true), {CFrame = currentCamera.CFrame + currentCamera.CFrame.LookVector * 0.5})
tween:Play()
task.wait(5.25)
resetCameraAndRespawn()
end
character.Humanoid.Died:Connect(function()
animationTrack:Play()
onDeath()
end)
Same.Did u fix that?
@davisossik nope
@@Novaledud u need to change tim to 2.7 or 2.8,it will work
@@Novaledud *time
Help me please :Animation is not a valid member of LocalScript "Workspace.Poatato15.Jumpscare" - Client - Jumpscare:13 here is my script
--{{Services}}--
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
--{{Variables}}--
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local currentCamera = game.Workspace.CurrentCamera
local rig = game.Workspace.JumpscareBox.Rig
--{{Functions}}--
local animationTrack = rig.Humanoid.Animator:LoadAnimation(script.JumpscareAnimation):Play()
local function onDeath()
currentCamera.CameraType = Enum.CameraType.Scriptable
currentCamera.CFrame = rig.Head.CFrame + (rig.Head.CFrame.LookVector * 3)
currentCamera.CFrame = CFrame.lookAt(((rig.Head.Position + Vector3.new(0, 1, 0))+(rig.Head.CFrame.LookVector * 3)), rig.Head.Position)
local tween = TweenService:Create(currentCamera, TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 13, true), {CFrame = currentCamera.CFrame + currentCamera.CFrame.LookVector * 0.5})
tween:Play()
task.wait(5)
currentCamera.CameraType = Enum.CameraType.Custom
end
character.Humanoid.Died:Connect(onDeath)
Maybe you forgot to add the animation inside the local script? Or you named it wrong.
Yeah maybe that
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local currentCamera = game.Workspace.CurrentCamera
local rig = game.Workspace.JumpscareBox.Rig
-- Make sure the animation is placed in ReplicatedStorage or adjust the path
local jumpscareAnimation = ReplicatedStorage:WaitForChild("JumpscareAnimation")
-- Load and play the animation
local animationTrack = rig.Humanoid:LoadAnimation(jumpscareAnimation)
animationTrack:Play()
-- Function to handle camera movement and transition on death
local function onDeath()
-- Change the camera type to scriptable to allow custom control
currentCamera.CameraType = Enum.CameraType.Scriptable
-- Position the camera behind the rig's head with an offset
local cameraOffset = rig.Head.CFrame.LookVector * -3 -- Camera placed behind the rig's head
local cameraPosition = rig.Head.Position + cameraOffset + Vector3.new(0, 1, 0)
-- Set the camera's CFrame to the new position, looking at the rig's head
currentCamera.CFrame = CFrame.new(cameraPosition, rig.Head.Position)
-- Create a smooth tween to slowly move the camera towards the rig's head
local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false)
local tweenGoal = {CFrame = currentCamera.CFrame + currentCamera.CFrame.LookVector * 0.5}
local tween = TweenService:Create(currentCamera, tweenInfo, tweenGoal)
tween:Play()
-- Wait for the tween to complete, then revert camera to default
task.wait(5)
currentCamera.CameraType = Enum.CameraType.Custom
end
-- Connect the death event to trigger the camera effect
character.Humanoid.Died:Connect(function()
-- Play the jumpscare animation on death
animationTrack:Play()
-- Trigger the camera change
onDeath()
end)
1:33 "hold shift to select all of them hold shift to select all of them
" bro rlly said it twice lol
does anyone know what's wrong with my code, i spelled it right and there's no errors but the animation doesn't play
{{Services}}
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
{{Variables}}
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local currentCamera = game.Workspace.CurrentCamera
local rig = game.Workspace.JumpscareBox.Sigma
{{Functions}}
local animationTrack = rig.Humanoid.Animator:LoadAnimation(script.JumpscareAnimation):Play()
local function onDeath()
currentCamera.CameraType = Enum.CameraType.Scriptable
currentCamera.CFrame = rig.Head.CFrame + (rig.Head.CFrame.LookVector * 3)
currentCamera.CFrame = CFrame.lookAt(((rig.Head.Position + Vector3.new(0, 0, 0))+(rig.Head.CFrame.LookVector * 3)), rig.Head.Position)
local tween = TweenService:Create(currentCamera, TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 13, true), {CFrame = currentCamera.CFrame + currentCamera.CFrame.LookVector * 0.5})
tween:Play()
task.wait(3)
currentCamera.CameraType = Enum.CameraType.Custom
end
character.Humanoid.Died:Connect(onDeath)
On line 18 my current camera has an error but the rest dont, no line of code has errors, all my spelling is right so can u tell me why
--{{Services}}--
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
--{{Variables}}--
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local currentCamera = game.Workspace.CurrentCamera
local rake = game.Workspace.JumpscareBox.Rake
--{{Functions}}--
local animationTrack = rake.Humanoid.Animator:LoadAnimation(script.JumpscareAnimation)
animationTrack:Play()
local function onDeath()
currentCamera.CameraType = Enum.CameraType.Scriptable
currentCamera.CFrame = rake.Head.CFrame + (rake.Head.CFrame.LookVector * 3)
currentCamera.CFrame = CFrame.lookAt(((rake.Head.Position + Vector3.new(0, 1, 0)) + (rake.Head.CFrame.LookVector * 3)), rake.Head.Position)
local tween = TweenService:Create(currentCamera, TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 13, true), {CFrame = currentCamera.CFrame + currentCamera.CFrame.LookVector * 0.5})
tween:Play()
task.wait(5)
currentCamera.CameraType = Enum.CameraType.Custom
end
local function onCharacterAdded(newCharacter)
character = newCharacter
character.Humanoid.Died:Connect(onDeath)
currentCamera.CameraType = Enum.CameraType.Custom -- Reset camera when respawning
end
player.CharacterAdded:Connect(onCharacterAdded)
-- Initial connection
if character then
character.Humanoid.Died:Connect(onDeath)
end
--{{Services}}--
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
--{{Variables}}--
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local currentCamera = game.Workspace.CurrentCamera
local rake = game.Workspace.JumpscareBox.Rake
--{{Functions}}--
local animationTrack = rake.Humanoid.Animator:LoadAnimation(script.JumpscareAnimation)
animationTrack:Play()
local function onDeath()
currentCamera.CameraType = Enum.CameraType.Scriptable
currentCamera.CFrame = rake.Head.CFrame + (rake.Head.CFrame.LookVector * 3)
currentCamera.CFrame = CFrame.lookAt(((rake.Head.Position + Vector3.new(0, 1, 0)) + (rake.Head.CFrame.LookVector * 3)), rake.Head.Position)
local tween = TweenService:Create(currentCamera, TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 13, true), {CFrame = currentCamera.CFrame + currentCamera.CFrame.LookVector * 0.5})
tween:Play()
task.wait(5)
currentCamera.CameraType = Enum.CameraType.Custom
end
local function onCharacterAdded(newCharacter)
character = newCharacter
character.Humanoid.Died:Connect(onDeath)
currentCamera.CameraType = Enum.CameraType.Custom -- Reset camera when respawning
end
player.CharacterAdded:Connect(onCharacterAdded)
-- Initial connection
if character then
character.Humanoid.Died:Connect(onDeath)
end
heres my script and everytime i die the camera is stuck on jumpscre box
the functions has a script error can anyone help?
I heard something in the background 10:05
his dog i think
Wow. It don’t work, what a waste of time
tysm but i want to make a horror game where a random person in the lobby is the killer and different maps like piggy could u pleasse make a tut for that!
BRO LEARN SCRIPTING STOP ASKING FOR TUTORIALS
You Didn't mencion the animationtrack on the script
Help! My animation isn’t playing if the code is correct
delete the :Play() part at the end of the animation track then write animationTrack:Play() below the tween:Play()
hope this helps
Thx
@@-stars.and.raindrops- No problem!
@@ShadowCodez-yk6wj Thanks, was wondering why the animation was playing whenever I spawned
@@rasheedgibbs9573 yea no problem!
THANK YOU
Thnxx
it didnt work when i die by the monster it doesnt work
how do I add a sound effect to make the monster more scary?
add the mewing song that goes BYE BYE
NOOOOO WHY DOESNT IT WORK FOR ME I WASTED FRICKIN 1 HOUR FOR THISSSSS
me too buddy, I understand
--{{ SERVICES }}--
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
--{{ VARIABLES }}--
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local currentCamera = game.Workspace.CurrentCamera
local rig = game.Workspace.JumpscareBox.HorrorMonster
--{{ FUNCTIONS }}--
local function playAnimation()
local animationTrack = rig.Humanoid.Animator:LoadAnimation(script.JumpscareAnimation)
animationTrack:Play()
end
local function resetCamera()
-- Ensure the camera is back to following the player
task.wait(1) -- Reduced wait time from 3 seconds to 2 seconds
currentCamera.CameraType = Enum.CameraType.Custom
currentCamera.CameraSubject = character:WaitForChild("Humanoid")
-- Lock the camera to first-person view
player.CameraMode = Enum.CameraMode.LockFirstPerson
currentCamera.FieldOfView = 70 -- Reset FOV to default for first-person view
end
local function onDeath()
-- Play the jumpscare animation
playAnimation()
-- Set the camera to scriptable mode and position it
currentCamera.CameraType = Enum.CameraType.Scriptable
currentCamera.CFrame = rig.Head.CFrame + (rig.Head.CFrame.LookVector * 3)
currentCamera.CFrame = CFrame.lookAt((rig.Head.Position + Vector3.new(0, 1, 0) + rig.Head.CFrame.LookVector * 3), rig.Head.Position)
-- Create a tween to move the camera slightly
local tween = TweenService:Create(
currentCamera,
TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 13, true),
{CFrame = currentCamera.CFrame + currentCamera.CFrame.LookVector * 0.5}
)
tween:Play()
-- Wait for the tween to finish
tween.Completed:Wait()
-- Reset the camera back to the player
resetCamera()
end
local function onCharacterAdded(newCharacter)
-- Update the character reference when the player respawns
character = newCharacter
-- Reset the camera type just in case it's still in scriptable mode
resetCamera()
-- Connect the onDeath function to the character's death event
character.Humanoid.Died:Connect(onDeath)
end
-- Connect the onCharacterAdded function to handle respawning
player.CharacterAdded:Connect(onCharacterAdded)
-- Initial setup when the script runs for the first time
onCharacterAdded(character) , make sure you change the monster in your game and your jumscare rig to HorrorMonster and it should work
-{SERVICES}-
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
-{VARIABLES}-
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local currentCamera = game.Workspace.CurrentCamera
local rig = game.Workspace.JumpscareBox.HorrorMonster
-{FUNCTIONS}-
local animationTrack = rig.Humanoid.Animator:LoadAnimation(script.JumpscareAnimation2):Play()
local function onDeath()
currentCamera.CameraType = Enum.CameraType.Scriptable
currentCamera.CFrame = rig.Head.CFrame + (rig.Head.CFrame.LookVector * 3)
currentCamera.CFrame = CFrame.lookAt(((rig.Head.Position + Vector3.new(0, 1, 0) + (rig.Head.CFrame.LookVector * 3)), rig.Head.Position))
local tween = TweenService:Create(currentCamera, TweenInfo.new(0.1 Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 13, true), {CFrame = currentCamera.CFrame + currentCamera.CFrame.LookVector * 0.5})
tween:Play()
task.wait(1000)
currentCamera.CameraType = Enum.CameraType.Custom
end
character.Humanoid.Died:Connect(onDeath)
same
Nice ❤🎉
Thanks 🤗
Mine isn't working.. can you help?
Giys if it’s a big monster do 25 that’s what I did with mine
for some reason id didnt work i did everything right but it failed
same
4:07
model?
tysm its working but anim is not playing(i fixed)
How did you fix it?
script for lazy people
This one works
-{SERVICES}-
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
-{VARIABLES}-
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local currentCamera = game.Workspace.CurrentCamera
local rig = game.Workspace.JumpscareBox.JumpscareMan
-{FUNCTIONS}-
local animationTrack = rig.Humanoid.Animator:LoadAnimation(script.JumpscareAnimation):Play()
local function onDeath()
currentCamera.CameraType = Enum.CameraType.Scriptable
currentCamera.CFrame = rig.Head.CFrame + (rig.Head.CFrame.LookVector * 3)
currentCamera.CFrame = CFrame.lookAt(((rig.Head.Position + Vector3.new(0, 1, 0) + (rig.Head.CFrame.LookVector * 3)), rig.Head.Position))
local tween = TweenService:Create(currentCamera, TweenInfo.new(0.1 Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 13, true), {CFrame = currentCamera.CFrame + currentCamera.CFrame.LookVector * 0.5})
tween:Play()
task.wait(1000)
currentCamera.CameraType = Enum.CameraType.Custom
end
character.Humanoid.Died:Connect(onDeath)
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local currentCamera = game.Workspace.CurrentCamera
local rig = game.Workspace.JumpscareBox.HorrorMonster
-- Ensure the animation track is properly loaded and played
local animationTrack = rig.Humanoid.Animator:LoadAnimation(script.JumpscareAnimation2)
animationTrack:Play()
local function onDeath()
currentCamera.CameraType = Enum.CameraType.Scriptable
currentCamera.CFrame = rig.Head.CFrame + (rig.Head.CFrame.LookVector * 3)
-- Fix CFrame.lookAt usage by correctly passing the position and target
currentCamera.CFrame = CFrame.lookAt(
rig.Head.Position + Vector3.new(0, 1, 0) + (rig.Head.CFrame.LookVector * 3),
rig.Head.Position
)
-- Create and play a tween with correct parameters
local tween = TweenService:Create(
currentCamera,
TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 13, true),
{CFrame = currentCamera.CFrame + currentCamera.CFrame.LookVector * 0.5}
)
tween:Play()
-- Wait for the tween to finish before resetting camera
task.wait(1) -- Adjusted wait time to match the tween duration
currentCamera.CameraType = Enum.CameraType.Custom
end
-- Connect the onDeath function to the humanoid's Died event
character.Humanoid.Died:Connect(onDeath)
gfuys fixed version
it doesnt work and i made sure i typed all the code right, do you know why?
Hi there! There could be a multiple of reasons that stop it from working. Try these:
1. Make sure that everything is spelled correctly.
2. Make sure that there are no errors in your script.
it didnt work 😪😪😪😪
It only works one time please help
GUYS ASK ME IF NEED HELP ILL GIVE SCRIPTS AND STUFF ALSO IF ANIMATION OR THE THING DOES POP UP MAKE SURE THE ANIMATION IS INSIDE OF "Jumpscare" and call the animaion "JumpscareAnimation" and call the jumpscare box "JumpscareBox" and make sure ur dummy is called "HorrorMonster" ask me for help!
the script for "Pathfindingscript" is
--{{ SERVICES }}--
local Players = game:GetService("Players")
local PathfindingService = game:GetService("PathfindingService")
--{{ VARIABLES }}--
local rig = script.Parent
local animations = script.Animations
--{{ FUNCTIONS }}--
local function checkForCharacter(character)
local rayOrigin = rig:FindFirstChild("HumanoidRootPart").Position
local rayDirection = (character.HumanoidRootPart.Position - rayOrigin).Unit * 40
local raycastResult = workspace:Raycast(rayOrigin, rayDirection, RaycastParams.new())
if raycastResult then
local raycastInstance = raycastResult.Instance
if raycastInstance:IsDescendantOf(character) then
return true
end
else
return false
end
end
local function findNearestPlayer()
local players = Players:GetPlayers()
local nearestPlayer = nil
local maxDistance = 63
for _, player in pairs(players) do
if player.Character ~= nil then
local targetCharacter = player.Character
local distance = (rig.HumanoidRootPart.Position - targetCharacter.HumanoidRootPart.Position).Magnitude
if distance < maxDistance and checkForCharacter(targetCharacter) then
nearestPlayer = targetCharacter
maxDistance = distance
end
end
end
return nearestPlayer
end
local function attack(character)
local distance = (rig.HumanoidRootPart.Position - character.HumanoidRootPart.Position).Magnitude
if distance > 4 then
rig.Humanoid:MoveTo(character.HumanoidRootPart.Position)
else
local attackAnimation = rig.Humanoid.Animator:LoadAnimation(animations.Attack)
attackAnimation:Play()
character.Humanoid.Health = 0
end
end
local function calculatePath(destination)
local agentParams = {
["AgentHeight"] = 5.5,
["AgentRadius"] = 4,
["AgentCanJump"] = false
}
local path = PathfindingService:CreatePath(agentParams)
path:ComputeAsync(rig.HumanoidRootPart.Position, destination)
return path
end
local function walkToDestination(destination)
local path = calculatePath(destination)
if path.Status == Enum.PathStatus.Success then
for _, waypoint in pairs(path:GetWaypoints()) do
local nearestPlayer = findNearestPlayer()
if nearestPlayer then
attack(nearestPlayer)
break
else
rig.Humanoid:MoveTo(waypoint.Position)
rig.Humanoid.MoveToFinished:Wait()
end
end
else
rig.Humanoid:MoveTo(destination - (rig.HumanoidRootPart.CFrame.LookVector * 10))
end
end
local function patrol()
local waypoints = workspace.Waypoints:GetChildren()
local randomNumber = math.random(1, #waypoints)
local walkAnimation = rig.Humanoid.Animator:LoadAnimation(animations.Walk)
walkAnimation:Play()
walkToDestination(waypoints[randomNumber].Position)
end
while task.wait(1) do
patrol()
end
make a localscript (Name the local script Jumpscare" inside of "StarterCharacterScripts" also put a animation inside of LocalScript and name the animation name "JumpscareAnimation" the script for the Jumpscare is
--{{ SERVICES }}--
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
--{{ VARIABLES }}--
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local currentCamera = game.Workspace.CurrentCamera
local rig = game.Workspace.JumpscareBox.HorrorMonster
--{{ FUNCTIONS }}--
local animationTrack = rig.Humanoid.Animator:LoadAnimation(script.JumpscareAnimation):Play()
local function onDeath()
currentCamera.CameraType = Enum.CameraType.Scriptable
currentCamera.CFrame = rig.Head.CFrame + (rig.Head.CFrame.LookVector * 3)
currentCamera.CFrame = CFrame.lookAt(((rig.Head.Position + Vector3.new(0, 1, 0)) + (rig.Head.CFrame.LookVector * 3)), rig.Head.Position)
local tween = TweenService:Create(currentCamera, TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 13, true), {CFrame = currentCamera.CFrame + currentCamera.CFrame.LookVector * 0.5})
tween:Play()
task.wait(3)
currentCamera.CameraType = Enum.CameraType.Custom
end
character.Humanoid.Died:Connect(onDeath)
what do you mean dummy? is it your avatar or the monster?
@@Abyssal_Vortex do you have to die from the monster for the jumpscare to activate or can you just reset
How do i add sound when i get jumpscared?
add a sound into the jumpscare box monster the under the tween:Play() write: SoundName:Play()
Help!!!
My animation plays exactly after 5 seconds the player died and the camera changed position, how can I delete this waiting time or make it shorter?
I checked the animation and it's starting on the "0" second bar.
My script:
-{{Services}}-
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
-{{Variables}}-
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local currentCamera = game.Workspace.CurrentCamera
local rig = game.Workspace.JumpscareBox.GranpaModel
local sound = game.Workspace.JumpscareBox.JumpscareSound2
-{{Functions}}-
local animationTrack = rig.Humanoid.Animator:LoadAnimation(script.JumpscareAnimation):Play()
local function onDeath()
currentCamera.CameraType = Enum.CameraType.Scriptable
currentCamera.CFrame = rig.Head.CFrame + (rig.Head.CFrame.LookVector * 3)
currentCamera.CFrame = CFrame.lookAt(((rig.Head.Position + Vector3.new(0, 0, 0))+(rig.Head.CFrame.LookVector * 3)), rig.Head.Position)
local tween = TweenService:Create(currentCamera, TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 13, true), {CFrame = currentCamera.CFrame + currentCamera.CFrame.LookVector * 0.5})
tween:Play()
task.wait(5)
currentCamera.CameraType = Enum.CameraType.Custom
end
character.Humanoid.Died:Connect(onDeath)
Thx for helping
task.wait(seconds you want to wait)
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
-{VARIABLES}-
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local currentCamera = game.Workspace.CurrentCamera
local rig = game.Workspace.JumpscareBox.HorrorMonster
-{FUNCTIONS}-
local animationTrack = rig.Humanoid.Animator:LoadAnimation(script.JumpscareAnimation2):Play()
local function onDeath()
currentCamera.CameraType = Enum.CameraType.Scriptable
currentCamera.CFrame = rig.Head.CFrame + (rig.Head.CFrame.LookVector * 3)
currentCamera.CFrame = CFrame.lookAt(((rig.Head.Position + Vector3.new(0, 1, 0) + (rig.Head.CFrame.LookVector * 3)), rig.Head.Position))
local tween = TweenService:Create(currentCamera, TweenInfo.new(0.1 Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 13, true), {CFrame = currentCamera.CFrame + currentCamera.CFrame.LookVector * 0.5})
tween:Play()
task.wait(1000)
currentCamera.CameraType = Enum.CameraType.Custom
end
character.Humanoid.Died:Connect(onDeath)
doesnt work tho
mines not working
Please add the script in the discription 😭😭
To not forget wheere i am - 6:42
it is not working
I wish I found your channel earlier !
Bro its not working
Free model?
You can find the free model in the description. Thanks for watching, have an amazing day!
@@rustysillyband thx!
@@rustysillyband I cant find the free model
I can find the model @@rustysillyband
I got it
OMG LIER I TOOK THIS SO HARD
hey love the previous tutorial and this one is pretty simple to follow but I keep getting an error when I run the game. Everything is spelled correctly and yet I keep getting this error
jumpscareAnim is not a valid member of LocalScript "Workspace.RitaMomentine.jumpscare" - Client - jumpscare:13
Any clue why?
It might be that the Jumpscare animation is taking too long to load in, so the script ends up running before the animation is there technically. To fix this, write: "local animation = script:WaitForChild("Animation") -- Change 'Animation' to the name of your animation.
Thanks for watching, have a great day!
@@rustysillyband Yes! I think that was exactly what the problem now! The script works flawlessly! Thank you again so much, hopefully I can make a really neat animation to go with this haha!
bad tutorial!
man shut yo ass up
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local currentCamera = game.Workspace.CurrentCamera
local rig = game.Workspace.JumpscareBox.HorrorMonster
-{FUNCTIONS}-
local animationTrack = rig.Humanoid.Animator:LoadAnimation(script.JumpscareAnimation2):Play()
local function onDeath()
currentCamera.CameraType = Enum.CameraType.Scriptable
currentCamera.CFrame = rig.Head.CFrame + (rig.Head.CFrame.LookVector * 3)
currentCamera.CFrame = CFrame.lookAt(((rig.Head.Position + Vector3.new(0, 1, 0) + (rig.Head.CFrame.LookVector * 3)), rig.Head.Position))
local tween = TweenService:Create(currentCamera, TweenInfo.new(0.1 Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 13, true), {CFrame = currentCamera.CFrame + currentCamera.CFrame.LookVector * 0.5})
tween:Play()
task.wait(1000)
currentCamera.CameraType = Enum.CameraType.Custom
end
character.Humanoid.Died:Connect(onDeath)