I am in the process of reworking all the tool animations for my game, and so far its been going pretty good, until I hit a bit of a wall with one of my animations.
The animation has shifted positions from what it looks like in the animation editor.
The intended look: (The hand is behind the characters back, like there hiding something)
What is shown in the game: (The hand is in front of the players torso, and it is sitting in a very awkward spot.
I have tried to adjust the positions of the animation to be more extreme, but it still doesn’t fix it. I have also adjusted the way the tool loads the animation but it also doesn’t work.
I think it might be something to do with the tools handle shifting the animation’s position but I’m not really sure (Still new to game development)
Here is the script and also the positions of the tool in the explorer:
-- Variables --
local Tool = script.Parent
local Handle = Tool:WaitForChild("Handle")
local AttackPart = Tool:WaitForChild("AttackPart")
local Model = Tool:WaitForChild("Model")
local Debounce = false
local PlayersHit = {}
-- Animation Variables --
local AttackAnimR6 = script:WaitForChild("GlassAttackR6")
local AttackAnimR15 = script:WaitForChild("GlassAttackR15")
local IdleR15 = script:WaitForChild("GlassIdleR15")
local IdleR6 = script:WaitForChild("GlassIdleR6")
local LocalPlayer = Tool.Parent.Parent
local BackPack = Tool.Parent
local PlayerChar = game.Workspace:WaitForChild(LocalPlayer.Name)
-- Weld Management --
for i, Parts in pairs(Model:GetChildren()) do
if Parts:IsA("BasePart") then
local Weld = Instance.new("WeldConstraint")
Weld.Part0 = Parts
Weld.Part1 = Handle
Weld.Parent = Parts
end
end
-- Animation Handler --
-- Idle --
Tool.Equipped:Connect(function()
if Tool.Parent == PlayerChar then
if Debounce ~= true then
local PlayerRigType = Tool.Parent.Humanoid.RigType
if PlayerRigType == Enum.HumanoidRigType.R6 then
local Humanoid = Tool.Parent:WaitForChild("Humanoid")
local AnimTrackIdleR6 = Humanoid.Animator:LoadAnimation(IdleR6)
-- Revert to original idle anim
AnimTrackIdleR6:Play()
Tool.Unequipped:Connect(function()
AnimTrackIdleR6:Stop()
end)
else
local Humanoid = Tool.Parent:WaitForChild("Humanoid")
local AnimTrackIdleR15 = Humanoid.Animator:LoadAnimation(IdleR15)
AnimTrackIdleR15:Play()
-- revert to orginal idle anim
Tool.Unequipped:Connect(function()
AnimTrackIdleR15:Stop()
end)
end
end
end
end)
-- Attack --
Tool.Activated:Connect(function()
if Debounce == false then
Debounce = true
local PlayerRigType = Tool.Parent.Humanoid.RigType
if PlayerRigType == Enum.HumanoidRigType.R15 then
local Humanoid = Tool.Parent:WaitForChild("Humanoid")
local AnimTrackR15 = Humanoid.Animator:LoadAnimation(AttackAnimR15)
AnimTrackR15:Play()
wait(0.5)
Debounce = false
else
local Humanoid = Tool.Parent:WaitForChild("Humanoid")
local AnimTrackR6 = Humanoid.Animator:LoadAnimation(AttackAnimR6)
AnimTrackR6:Play()
wait(0.5)
Debounce = false
end
end
end)
-- Damage --
AttackPart.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("ImNPC!") and Hit.Parent ~= Tool.Parent then
if Debounce == true and PlayersHit[Hit.Parent] == nil then
Hit.Parent:FindFirstChild("Humanoid"):TakeDamage(9)
local FindAttackerString = Hit.Parent:FindFirstChild("Attacker")
FindAttackerString.Value = script.Parent.Parent.Name
PlayersHit[Hit.Parent] = true
wait(0.5)
PlayersHit[Hit.Parent] = nil
end
end
end)
(The script is a heavily modified version of two youtubers tutorials)