I’m trying to play a one-handed thrust animation on my spear.
The spear is much shakier when the animation is played in-game than in the editor, and it doesn’t quite extend as far.
It still runs into this issue no matter what animation priority I set it to (I have it on action2) and cancelling the spear’s idle didn’t help either.
In case it helps, here is the code:
-- This is an example Lua code block
local userInputService = game:GetService("UserInputService")
local tool = script.Parent
local cooldown = false
local cooldown2 = false
wait(0.2)
local char = game.Players.LocalPlayer.Character
local humanoid = char.Humanoid
local HoldTrack = humanoid:LoadAnimation(tool.Animations.Hold)
local StabTrack = humanoid:LoadAnimation(tool.Animations.Stab)
local ThrustTrack = humanoid:LoadAnimation(tool.Animations.Thrust)
script.Parent.Equipped:Connect(function()
--game.ReplicatedStorage.SpearHoldStart:Fire()
HoldTrack:Play()
end)
script.Parent.Unequipped:Connect(function()
--game.ReplicatedStorage.SpearHoldEnd:Fire()
HoldTrack:Stop()
end)
script.Parent.Activated:Connect(function()
if cooldown == false then
cooldown = true
--game.ReplicatedStorage.SpearClick:Fire()
StabTrack:Play()
tool.Click:FireServer("Stab")
wait(0.9)
cooldown = false
end
end)
userInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.Q and cooldown2 == false then
cooldown2 = true
ThrustTrack:Play()
tool.Click:FireServer("Thrust")
wait(1.2)
cooldown2 = false
end
end
end)