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))
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()
--{{ 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
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
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)
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)
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!
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!
@@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!
--{{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
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)
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
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.
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!
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
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()
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
Thank you for these kind of videos
Thank you so much you make things so simple
Thanks bro! Helped a lot!
i need this for my horror game thanks! (Rate: 10/10)
very useful, you deserve more attraction to your channel.
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
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
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)
Very good thanks man
Can you make a daily reward system tutorial? Btw your editing is too good. Good job rusty.
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?
thanks so much! i needed this for my horror game
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!
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.
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
Nice ❤🎉
Thanks 🤗
I heard something in the background 10:05
Thnxx
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
--{{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
for some reason id didnt work i did everything right but it failed
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)
how do I add a sound effect to make the monster more scary?
add the mewing song that goes BYE BYE
Mine isn't working.. can you help?
Giys if it’s a big monster do 25 that’s what I did with mine
yo can you copy the script in the discription
I got it
It only works one time please help
Bro its not working
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)
model?
I wish I found your channel earlier !
mines not working
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.
To not forget wheere i am - 6:42
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()
Please add the script in the discription 😭😭
it didnt work 😪😪😪😪
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
bad tutorial!
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!