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?