I made a swing animation, but for some reason the bat moves differently then I animated it.
Gameplay:
[]
Animation:
I made a swing animation, but for some reason the bat moves differently then I animated it.
Gameplay:
[]
Animation:
Go back in the animation. Change the animation priority to action. Then override the published animation. See if that works.
It was previously at Action3, I have now changed it to action4, it still doesn’t work.
Here’s the script if it might help.
local tool = script.Parent
local Idle = Instance.new("Animation")
local Equip = Instance.new("Animation")
local Swing = Instance.new("Animation")
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local handle = tool.Handle
Idle.Name = "IdleAnim"
Idle.AnimationId = "rbxassetid://10662611565" -- Idle animaton ID here
Equip.Name = "EquipAnim"
Equip.AnimationId = "rbxassetid://10723444666" -- Idle animaton ID here
Swing.Name = "SwingAnim"
Swing.AnimationId = "rbxassetid://10662345775" -- Idle animaton ID here
local children = tool.Handle:GetChildren()
local track
local debounce = false
tool.Equipped:Connect(function()
track = humanoid:LoadAnimation(Equip)
track.Priority = Enum.AnimationPriority.Action
track:Play()
track:GetMarkerReachedSignal("Invisible"):Connect(function()
tool.Handle.Transparency = 1
tool.Handle.CanCollide = false
for i,part in ipairs(tool:GetDescendants()) do
if part:IsA("Part") or part:IsA("MeshPart") then
part.Transparency = 1
--this code runs whenever its part or meshpart
end
end
end)
track:GetMarkerReachedSignal("Visible"):Connect(function()
tool.Handle.Transparency = 0
tool.Handle.CanCollide = true
for i,part in ipairs(tool:GetDescendants()) do
if part:IsA("Part") or part:IsA("MeshPart") then
part.Transparency = 0
--this code runs whenever its part or meshpart
end
end
end)
track.Stopped:Wait()
track = humanoid:LoadAnimation(Idle)
track.Priority = Enum.AnimationPriority.Action2
track:Play()
end)
tool.Unequipped:Connect(function()
if track then
track:Stop()
end
end)
tool.Activated:Connect(function()
debounce = true
track = humanoid:LoadAnimation(Swing)
track.Priority = Enum.AnimationPriority.Action4
track:Play()
handle.Touched:Connect(function(Hit)
if Hit:IsA("Part") or Hit:IsA("MeshPart") then
if Hit.Parent ~= character then
local EHumRP = Hit.Parent:FindFirstChild("HumanoidRootPart")
local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
if Humanoid then
Humanoid:TakeDamage(20)
end
end
end
end)
track.Stopped:Wait()
debounce = false
end)
Animating the handle’s CFrame wouldn’t work as it is locked to the player’s right arm grip attachment, offsetted and rotated based on four parameters on the tool (shown below). To make the bat angle and offset it’s position, you would have animate the grip positions. I’m not sure if Moon Animator or any other animation plugins are capable of animating grip positions.
Hm, I’ll look more into it.
letter limit
Hiya, I’ve made a similar system that I haven’t really tested to solve this issue. Does the animating rig have the tool’s handle with a Motor6D in the right arm? Your tool is likely doing that because of Roblox - Roblox automatically creates a weld within the right arm of a character if a tool has a handle. If the Motor6D you animated the tool with is inside the right arm, here is a script to fix this issue:
[Script named Motor6D within the tool]
function createmotor()
local right_arm = Tool.Parent:WaitForChild('Right Arm')
if right_arm:FindFirstChildOfClass('Weld') then
right_arm:FindFirstChildOfClass('Weld'):Destroy()
end
local sr = script:WaitForChild('move'):Clone()
m6d = Instance.new('Motor6D')
m6d.Name = 'bat6D'
m6d.Part0 = right_arm
if script.Parent:FindFirstChild('Handle') then
m6d.Part1 = script.Parent:FindFirstChild('Handle')
m6d.CurrentAngle = 0
m6d.DesiredAngle = 0
m6d.MaxVelocity = 1000
m6d.Parent = right_arm
sr.Disabled = false
sr.Parent = m6d
end
end
function onEquipped()
if Tool.Parent:FindFirstChild('Right Arm') then
createmotor()
end
end
function destroy6d()
if m6d then
m6d:Destroy()
end
m6d = nil
end
Tool.Equipped:connect(onEquipped)
Tool.Unequipped:connect(destroy6d)
[Script named ‘move’ (without the quotes) parented to the script]
if script.Parent.Parent:WaitForChild('RightGrip') then
script.Parent.Parent:WaitForChild('RightGrip'):Destroy()
end
Not sure if this is exploitable or not.
@NarutoandGokuUi101
Hm, Sorry for getting back so late, I was kind of busy. My motor6D is parented to the HUMRP to make animation a slight bit easier, so maybe if I modify it, it might also help me out, thanks though.
You can disregard the following post if you’ve fixed that -
function createmotor()
local right_arm = Tool.Parent:WaitForChild('Right Arm')
if right_arm:FindFirstChildOfClass('Weld') then
right_arm:FindFirstChildOfClass('Weld'):Destroy()
end
sr = script:WaitForChild('move'):Clone()
m6d = Instance.new('Motor6D')
m6d.Name = 'bat6D'
m6d.Part0 = right_arm.Parent:WaitForChild('HumanoidRootPart')
if script.Parent:FindFirstChild('Handle') then
m6d.Part1 = script.Parent:FindFirstChild('Handle')
m6d.CurrentAngle = 0
m6d.DesiredAngle = 0
m6d.MaxVelocity = 1000
m6d.Parent = right_arm.Parent:WaitForChild('HumanoidRootPart')
sr.Disabled = false
sr.Parent = m6d
end
end
function onEquipped()
if Tool.Parent:FindFirstChild('Right Arm') then
createmotor()
end
end
function destroy6d()
if m6d then
m6d:Destroy()
end
m6d = nil
sr:Destroy() --fixed memory leak (oops)
end
Tool.Equipped:connect(onEquipped)
Tool.Unequipped:connect(destroy6d)
And then parent the second script to the first script.
If you’ve implemented a fix, then perfect! Good job