Jump Scare wont work

Hi all
i am making a horror game and i have made a script which triggers a jumpscare when a player touches the trigger but for some reason it is not working

Problem 1.the camera angle wont change

Problem2.The Sound wont play

Here’s the script



local Camera = game.Workspace.Camera
local Angle = game.Workspace.Angle
local Doll = game.Workspace.Doll
local Trigger = script.Parent
local Scream = script.Parent.Scream

Trigger.Touched:Connect(function(hit)
	if hit and hit.Parent:FindFirstChild("Humanoid")then
		Trigger:Destroy()
		Camera.CameraType = Enum.CameraType.Scriptable
		Camera.CFrame = Angle.CFrame
		Scream:Play()
		Scream.Volume = 3
		wait(0.9)
		Camera.CameraType = Enum.CameraType.Custom
	end
end)

Hi,
I think your problem is that you put “Music” in Trigger.
obraz_2022-02-07_153622

After Humanoid hit Trigger it Destroys Trigger and all items he contains ( Music, Script ).
You should fix it or change Trigger:Destroy() line

local Camera = game.Workspace.Camera
local Angle = game.Workspace.Angle
local Doll = game.Workspace.Doll
local Trigger = script.Parent
local Scream = script.Parent.Scream

Trigger.Touched:Connect(function(hit)
	if hit and hit.Parent:FindFirstChild("Humanoid")then
		Camera.CameraType = Enum.CameraType.Scriptable
		Camera.CFrame = Angle.CFrame
		Scream:Play()
		Scream.Volume = 3
		wait(0.9)
        Trigger:Destroy()
		Camera.CameraType = Enum.CameraType.Custom
	end
end)

thank you
the sound is being payed but the camera is still not working for some reason
is there any fix for that?

I’m not sure because I mostly script GUI.
But you should move Trigger:Destroy() to the end

local Camera = game.Workspace.Camera
local Angle = game.Workspace.Angle
local Doll = game.Workspace.Doll
local Trigger = script.Parent
local Scream = script.Parent.Scream

Trigger.Touched:Connect(function(hit)
	if hit and hit.Parent:FindFirstChild("Humanoid")then
		Camera.CameraType = Enum.CameraType.Scriptable
		Camera.CFrame = Angle.CFrame
		Scream:Play()
		Scream.Volume = 3
		wait(0.9)
		Camera.CameraType = Enum.CameraType.Custom
        Trigger:Destroy()
	end
end)

If this doesn’t work, I can’t help you.

that’s okay
thank you for the help

Np, and you should do

local work = game:GetService("Workspace")


local Camera = work:WaitForChild("Camera")
local Angle = work:WaitForChild("Angle")
local Doll = work:WaitForChild("Doll")
local Trigger = script.Parent
local Scream = script.Parent.Scream

Trigger.Touched:Connect(function(hit)
	if hit and hit.Parent:FindFirstChild("Humanoid")then
                Camera.CameraType = Enum.CameraType.Scriptable
		Camera.CFrame = Angle.CFrame
		Scream:Play()
		Scream.Volume = 3
		wait(0.9)
	        Camera.CameraType = Enum.CameraType.Custom
		Trigger:Destroy()
	end
end)

This should fix all your issues:

local Camera = game.Workspace.Camera
local Angle = game.Workspace.Angle
local Doll = game.Workspace.Doll
local Trigger = script.Parent
local Scream = script.Parent.Scream


Trigger.Touched:Connect(function(hit)
	if hit and hit.Parent:FindFirstChild("Humanoid")then
		Camera.CameraType = Enum.CameraType.Scriptable
		Camera.CFrame = Angle.CFrame
                Scream.Volume = 3
		Scream:Play()
		
		wait(0.9)
                Trigger:Destroy()
		Camera.CameraType = Enum.CameraType.Custom
	end
end)

Also add a debounce to your script, just in case

Is this a server script? The server’s camera does not belong to any particular player, you’ll need to fire the specific client (which should be “jumpscared”) and manipulate their camera locally.