Keyframe animations are not checked

So I have a local script:

local uis = game:GetService("UserInputService")
local tool = script.Parent
local anim = tool:WaitForChild("Throw")
local track = nil
local event = tool:WaitForChild("ThrowingEvent")
local equipped = false
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
--local animator = hum:FindFirstChild("Animator") or Instance.new("Animator", hum)
local animator = hum.Animator
local track = animator:LoadAnimation(anim)

tool.Equipped:Connect(function()
	equipped = true
	print("equipped")
	track.KeyframeReached:Connect(function(Kfname)
		print("testGo")
		if Kfname == "Release" then
			print("Keyframe")
			event:FireServer()
		end
	end)
end)

tool.Unequipped:Connect(function()
	equipped = false
end)

uis.InputBegan:Connect(function(input)
	if equipped and input.UserInputType == Enum.UserInputType.MouseButton1 then
		track:Play()
	end
	
	if equipped and input.UserInputType == Enum.UserInputType.Touch then
		track:Play()
	end
end)

Script:

local tool = script.Parent
local event = script.Parent:WaitForChild("ThrowingEvent")
local debris = game:GetService("Debris")

event.OnServerEvent:Connect(function(player)
	local dynamite = tool.Handle:Clone()
	dynamite.Parent = workspace
	dynamite.CanCollide = true
	local char = player.Character or player.CharacterAdded:Wait()
	local hrp = char:WaitForChild("HumanoidRootPart")
	local dir = hrp.CFrame.LookVector + hrp.CFrame.UpVector
	dynamite.VectorForce.Force = dir * 10
	tool:Destroy()
	wait(0.2)
	dynamite.VectorForce.Enabled = false
	wait(1.5)
	dynamite.ExploseSound:Play()
	
	local vfx = Instance.new("Explosion", workspace)
	vfx.Position = dynamite.Position
	vfx.BlastRadius = 20
	vfx.BlastPressure = 500000
	dynamite.Transparency = 1
	dynamite.Anchored = true
	dynamite.CanCollide = false
	debris:AddItem(dynamite, 2.2)
	
	
end)

With these scripts, I throw dynamite, but I want it to be thrown at a certain point in my animation. But for some reason, I do not get to the function in the animation on line 18. That is, the first print is written, but the others do not.

What may be the problem?

1 Like

Try printing the AnimationTrack after you have created variable with loaded animation and checking if track is actually playing on the client script. The server script is fine but the problem is that Keyframe which is suppose to be detected on the client script doesn’t being detected.

1 Like

Here I printed it out and this is what it says:

1 Like

Great, it means that the animation is loaded into Humanoid

Now check if your AnimationTrack does play after Equipped event.

1 Like

Well, here’s how I understand it plays out. After all, the animation itself works, but I do not get into that function
Ну Π²ΠΎΡ‚ ΠΊΠ°ΠΊ я понял воспроизводится. Π’Π΅Π΄ΡŒ сама Ρ‚ΠΎ анимация Ρ€Π°Π±ΠΎΡ‚Π°Π΅Ρ‚, Ρ‚ΠΎΠ»ΡŒΠΊΠΎ Π²ΠΎΡ‚ Π² Ρ„ΡƒΠ½ΠΊΡ†ΠΈΡŽ я Π½Π΅ попадаю

1 Like

Maybe try using Animation Events?
I saw several reports that KeyframeReached event doesn’t fire sometimes but may be you could change KeyframeReached event to another event that can detect whenever marker is being reached.
Personally, i haven’t used KeyframeReached but this event is same as Animation Events so i keeping using this.
I’d try recommending Animation Event as other solution as this is simple to use but require to have Animation Markers in your animation so you could detect special markers in your animation

1 Like