The script only works if I test the game through Run

The script only works if I test the game through Run. When im testing in game through Play
Script (ServerScript not LocalScript)

local hum = script.Parent:WaitForChild("ColdBloodedKiller")
while wait() do
	local humanim = hum:LoadAnimation(script.Parent:FindFirstChildOfClass("Animation"))
	if game.Workspace.MonitorOpening.Scared.Value == true then
		game.Workspace.Camera.CameraType = Enum.CameraType.Scriptable
		game.Workspace.Camera.CFrame = game.Workspace.MonitorOpening.CFrame
			script.Parent:SetPrimaryPartCFrame(game.Workspace.BonnieScreamer.CFrame)
			game.Workspace.Jumpscare:Play()
		humanim:Play()
		wait(100)
	end
end

What could be the reason for this problem?

You can’t set a player’s camera in a Server Script, it must be done through local.

Okay. Thanks for a help! I’m try it.

I’m remade the script into local script and this not working.

where is the local script located?

Just remove the second wait, it probably makes it slower.

local hum = script.Parent:WaitForChild("ColdBloodedKiller")
while task.wait() do
	local humanim = hum:LoadAnimation(script.Parent:FindFirstChildOfClass("Animation"))
	if game.Workspace.MonitorOpening.Scared.Value == true then
		game.Workspace.Camera.CameraType = Enum.CameraType.Scriptable
		game.Workspace.Camera.CFrame = game.Workspace.MonitorOpening.CFrame
			script.Parent:SetPrimaryPartCFrame(game.Workspace.BonnieScreamer.CFrame)
			game.Workspace.Jumpscare:Play()
		humanim:Play()
	end
end

Nope. When im testing game through Run, the camera works and the jumpscare works. If i’m remove second wait he start loop jumpscare sound and animation so fast.

In the BonnieScreamer(model). Not in StarterGUI

But i’m try this. If this helps me I’ll write to you

Im tested, but this nor working.

I found a similar issue and the fix was to enable looping in the animatoion editor rather than scriot.

well then it wont work. local scripts work in starter gui, starter pack, and starter player scripts

I’m remade to script. This still not working.

But why this work when im testing not as a player?