Hello, im working on a knife framework. I try to create it myself because it needed to work on NPC’s too and i will code it too after solve my problem.
My problem is about Animation. I got message “ok3” but my animation isn’t playing.
local Anim
local IsAnim, IsEnabled = false, false
local plr = script.Parent.Parent.Parent
script.Parent.Play.OnServerEvent:Connect(function()
if IsEnabled == true then
local Anim = plr.Character.Humanoid:LoadAnimation(script.Parent.KnifeAnim)
if IsAnim == false then
Anim:Play()
print("ok3")
IsAnim = true
coroutine.wrap(WaitAnimation)()
elseif IsAnim == true then
Anim:Stop()
Anim:Play()
coroutine.wrap(WaitAnimation)()
end
end
end)
function WaitAnimation()
if Anim ~= nil then
while Anim.IsPlaying == true do
wait()
end
if Anim.IsPlaying == false then
IsAnim = false
end
end
end
script.Parent.Handle.Touched:Connect(function(hit)
if hit.Parent:WaitForChild("Humanoid") then
hit.Parent:WaitForChild("Humanoid"):TakeDamage(hit.Parent:WaitForChild("Humanoid").Health)
end
end)
script.Parent.Equipped:Connect(function()
IsEnabled = true
end)
script.Parent.Unequipped:Connect(function()
IsEnabled = false
end)
Animation property is on action. Not Local Script, Animation ID is valid. I don’t know why i got this problem. “KnifeAnim is an Animation”