Animation Error

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I’m making an animation for the end of the chase in my indie horror game.

  2. What is the issue? Include screenshots / videos if possible!
    All of the prints are firing, but for some reason, the animation isn’t playing.
    Output:

Server: Player superman978705 triggered ChasePhaseTwo  -  Server - PhaseTwoStarter:16
  16:19:02.944  Server: Fired DisableEvent for superman978705  -  Server - PhaseTwoStarter:20
  16:19:02.944  Server: Fired ChasePhaseTwo event for all clients  -  Server - PhaseTwoStarter:22
  16:19:03.299  Client: Received ChasePhaseTwo event  -  Client - PhaseTwoHandler:61
  16:19:03.300  Client: Player character found  -  Client - PhaseTwoHandler:69
  16:19:09.459  Server: Cutscene wait complete, teleporting player  -  Server - PhaseTwoStarter:26
  16:19:09.460  Server: Teleported superman978705 to EndChaseTeleportPosition  -  Server - PhaseTwoStarter:32
  16:19:09.460  Server: Fired EnableEvent for superman978705  -  Server - PhaseTwoStarter:39

Then it still does teleport me.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    So, so many dev forum posts. ChatGPT, the talent hub finding someone who can help.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

LocalScript

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local ContentProvider = game:GetService("ContentProvider")

local player = Players.LocalPlayer
local camera = workspace.CurrentCamera

local Event = ReplicatedStorage.Remotes:WaitForChild("ChasePhaseTwo")
local Characters = ReplicatedStorage:WaitForChild("EndChaseAnimation")
local John = Characters:WaitForChild("NaughtyJohn")
local Main = Characters:WaitForChild("PlayerModel")

local ChaseTriggerer = workspace:WaitForChild("ObjectiveParts"):WaitForChild("ChasePhaseTwo")

-- Utility: Disable collisions
local function disableCollisions(model)
	if not model then
		warn("Client: No model provided for disableCollisions")
		return
	end
	for _, part in ipairs(model:GetDescendants()) do
		if part:IsA("BasePart") then
			part.CanCollide = false
		end
	end
end

-- Make player invisible/visible
local function setPlayerVisible(character, isVisible)
	if not character then
		warn("Client: No character found for visibility toggle")
		return
	end
	print("Client: Setting player visibility to " .. tostring(isVisible))
	for _, part in ipairs(character:GetDescendants()) do
		if part:IsA("BasePart") or part:IsA("Decal") then
			part.Transparency = isVisible and 0 or 1
		elseif part:IsA("Accessory") and part:FindFirstChild("Handle") then
			part.Handle.Transparency = isVisible and 0 or 1
		elseif part:IsA("ParticleEmitter") then
			part.Enabled = isVisible
		end
	end
end

-- Preload cutscene assets
local function preloadCharacters()
	print("Client: Preloading cutscene assets")
	local assets = {}
	for _, desc in ipairs(Characters:GetDescendants()) do
		if desc:IsA("MeshPart") or desc:IsA("Decal") or desc:IsA("Texture") or desc:IsA("Animation") then
			table.insert(assets, desc)
		end
	end
	ContentProvider:PreloadAsync(assets)
	print("Client: Asset preloading complete")
end

Event.OnClientEvent:Connect(function()
	print("Client: Received ChasePhaseTwo event")
	local success, err = pcall(function()
		-- Validate character
		local character = player.Character or player.CharacterAdded:Wait()
		if not character then
			warn("Client: Player character not found")
			return
		end
		print("Client: Player character found")

		-- Wait for game to load
		game.Loaded:Wait()
		print("Client: Game loaded, proceeding with cutscene setup")

		-- Validate MainAnimationStartPoint
		local targetCFrame = workspace:WaitForChild("MainAnimationStartPoint", 10)
		if not targetCFrame then
			warn("Client: MainAnimationStartPoint not found in Workspace after waiting")
			return
		end
		print("Client: Found MainAnimationStartPoint")

		-- Hide player
		setPlayerVisible(character, false)

		-- Preload assets and force streaming
		preloadCharacters()
		player:RequestStreamAroundAsync(targetCFrame.Position, 1)
		task.wait(1)
		print("Client: Streaming requested and assets preloaded")

		-- Move cutscene models to workspace
		Characters.Parent = workspace
		if ChaseTriggerer then
			ChaseTriggerer:Destroy()
			print("Client: ChaseTriggerer destroyed")
		end

		-- Validate model structure
		local mainPrimary = Main:FindFirstChild("PrimaryPart")
		local johnPrimary = John:FindFirstChild("PrimaryPart")
		if not mainPrimary or not johnPrimary then
			warn("Client: PrimaryPart missing on Main or John")
			return
		end
		print("Client: PrimaryParts found for Main and John")

		-- Reposition John relative to PlayerModel
		local offsetCFrame = mainPrimary.CFrame:ToObjectSpace(johnPrimary.CFrame)
		Main:PivotTo(targetCFrame.CFrame)
		John:PivotTo(mainPrimary.CFrame * offsetCFrame)
		print("Client: Repositioned Main and John models")

		-- Disable collisions
		disableCollisions(John)
		print("Client: Disabled collisions for John")

		-- Load animations
		local JohnAnim = script:WaitForChild("John", 5)
		local MainAnim = script:WaitForChild("Player", 5)
		if not JohnAnim or not MainAnim then
			warn("Client: Failed to find John or Player animation in script")
			return
		end
		print("Client: Found John and Player animations")

		-- Validate humanoids
		local JohnHumanoid = John:WaitForChild("Humanoid", 5)
		local MainHumanoid = Main:WaitForChild("Humanoid", 5)
		if not JohnHumanoid or not MainHumanoid then
			warn("Client: Humanoid missing in John or Main")
			return
		end
		print("Client: Found Humanoids for John and Main")

		-- Load animation tracks
		local JohnAnimTrack = JohnHumanoid:LoadAnimation(JohnAnim)
		local MainAnimTrack = MainHumanoid:LoadAnimation(MainAnim)
		if not JohnAnimTrack or not MainAnimTrack then
			warn("Client: Failed to load animation tracks")
			return
		end
		print("Client: Loaded animation tracks")

		JohnAnimTrack.Priority = Enum.AnimationPriority.Action4
		MainAnimTrack.Priority = Enum.AnimationPriority.Action4

		-- Set up camera
		local torso = Main:WaitForChild("Torso", 5)
		if not torso then
			warn("Client: Torso not found in Main")
			return
		end
		camera.CameraSubject = torso
		camera.CameraType = Enum.CameraType.Custom
		camera.CFrame = camera.CFrame * CFrame.new(0, 5, -10)
		print("Client: Camera set up for cutscene")

		-- Play animations
		JohnAnimTrack:Play()
		MainAnimTrack:Play()
		print("Client: Playing John and Main animations")

		-- Handle animation end
		MainAnimTrack.Ended:Connect(function()
			print("Client: Main animation ended")
			-- Reset camera
			if player.Character and player.Character:FindFirstChild("Head") then
				camera.CameraSubject = player.Character.Head
			end
			camera.CameraType = Enum.CameraType.Custom
			print("Client: Camera reset to player head")

			-- Show player again
			setPlayerVisible(player.Character, true)
			print("Client: Player visibility restored")
		end)
	end)

	if not success then
		warn("Client: Error in ChasePhaseTwo handler: " .. tostring(err))
	end
end)

ServerScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local Event = ReplicatedStorage.Remotes:WaitForChild("ChasePhaseTwo")
local DisableEvent = ReplicatedStorage.Remotes:WaitForChild("DisableControls")
local EnableEvent = ReplicatedStorage.Remotes:WaitForChild("EnableControls")

local debounce = {}

script.Parent.Touched:Connect(function(hit)
	local character = hit.Parent
	local player = Players:GetPlayerFromCharacter(character)

	if player and character:FindFirstChild("Humanoid") and not debounce[player] then
		debounce[player] = true
		print("Server: Player " .. player.Name .. " triggered ChasePhaseTwo")

		-- Disable controls and trigger cutscene
		DisableEvent:FireClient(player)
		print("Server: Fired DisableEvent for " .. player.Name)
		Event:FireAllClients()
		print("Server: Fired ChasePhaseTwo event for all clients")

		-- Wait for cutscene duration (adjust to match animation length)
		task.wait(6.5)
		print("Server: Cutscene wait complete, teleporting player")

		-- Teleport player to EndChaseTeleportPosition
		local teleportTarget = workspace:WaitForChild("EndChaseTeleportPosition", 10)
		if teleportTarget then
			character:MoveTo(teleportTarget.Position + Vector3.new(0, 2, 0))
			print("Server: Teleported " .. player.Name .. " to EndChaseTeleportPosition")
		else
			warn("Server: EndChaseTeleportPosition not found in Workspace after waiting")
		end

		-- Re-enable controls
		EnableEvent:FireClient(player)
		print("Server: Fired EnableEvent for " .. player.Name)

		-- Clear debounce
		task.wait(2)
		debounce[player] = nil
		print("Server: Debounce cleared for " .. player.Name)
	end
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

What exactly is the problem now? You added print in your code and the print you wrote are displayed in the console
What exactly is the problem?


You seem to trying to play the animation for another character ( not yours ) maybe that’s the reason.

If I remember correctly you can only do that on the server / or on the client for characters that you have network ownership for.

And have you tried using the Animator?

1 Like

Yes, that’s supposed to happen. The character isn’t used in the animation :slight_smile:

Your replying to this?

If that’s the case, have you tried my suggestions?

I will try both of these soon. (I believe the humanoid works better for R6 animations though)