Cutscene Animation Not Working

Hi so i was trying to make a cutscene and this kept happening.
It plays the wrong animation for some reason.

It doesnt give out a error and this is the script.

function onTouched(hit)
	if hit.Parent:FindFirstChild("HumanoidRootPart") and hit.Parent.Name ~= "Killer" then
		local root = game.Workspace.Killer.HumanoidRootPart
		local position = script.Parent:FindFirstChild("Victim").Position
		local ori = script.Parent:FindFirstChild("Victim").Orientation
		local posx = hit.Parent:FindFirstChild("HumanoidRootPart").Position.X
		hit.Parent:FindFirstChild("HumanoidRootPart").Position = Vector3.new(posx, position.Y, position.Z)
		hit.Parent:FindFirstChild("HumanoidRootPart").Orientation = Vector3.new(ori.X, ori.Y, ori.Z)
		root.Position = Vector3.new(posx, root.Position.Y, root.Position.Z)
		root.Orientation = Vector3.new(root.Orientation.X, root.Orientation.Y, root.Orientation.Z)
		hit.Parent:FindFirstChild("HumanoidRootPart").Anchored = true
		root.Anchored = true
		local clone = script.Parent.VictimAnim:Clone()
		clone.Parent = hit.Parent
		clone.Enabled = true
		local clone2 = script.Parent.KillerAnim:Clone()
		clone.Parent = root.Parent
		clone2.Enabled = true
	end
end

script.Parent.Touched:connect(onTouched)


Can someone please help me?

3 Likes

You probably have the humanoid/animator loading the wrong animations.

3 Likes

And how do i fix that? Can you tell me?

2 Likes

You probably have it like this:
Killer.Humanoid:LoadAnimation(clone)

Do this:
Killer.Humanoid:LoadAnimation(clone2)

this is the animation script

local hum = script.Parent:WaitForChild("Humanoid")
local anim = hum:LoadAnimation(script:FindFirstChildOfClass("Animation"))
anim:Play()

anim.KeyframeReached:Connect(function(keyframeName)
	if keyframeName == "Death" then
		anim:AdjustSpeed(0)
		hum.Health = 1
		hum.Health = 0
		script.Parent.Torso.Anchored = true
	end
end)

Can you show me the output error too?
Edit: I’m blind. You said there was no error. Possibly reread your code. You might be misplacing victim and yourself

there is no output error idk why

i think i found the error… do you want me to show it?

Yes, you should. I’d like to see the error

the error was i was parenting both the scripts to the killer, sorry man. i couldnt see. i will still set your answer as the solution as that helped me.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.