I have a drill rifle that i bought from someone and im supposed to just add my animation to the module script and it works fine the only issue is that the gun doesnt point where its supposed to.
Explorer:
ModuleScript:
local module = {
--[[ 93486321133853
NOTE: The first animation of the list will be the default animation played when the weapon is equipped.
FORMAT:
{
AnimationID = 0,
Keybind = Enum.KeyCode.Key,
Name = "",
ToolNames = {"Name", "Name"}, -- This is for specifying what the tool name must be for this animation, in case you have multiple tools with different animations each.
},
]]
{
AnimationID = 123618343028591,
Keybind = Enum.KeyCode.F,
Name = "Shoulder Arms",
ToolNames = {"Drill Rifle"},
},
{
AnimationID = 88107498671636,
Keybind = Enum.KeyCode.H,
Name = "Port Arms",
ToolNames = {"Drill Rifle"},
},
{
AnimationID = 103378953035890,
Keybind = Enum.KeyCode.V,
Name = "Present Arms",
ToolNames = {"Drill Rifle"},
},
{ -- MY CUSTOM ANIM
AnimationID = 103970454036833,
Keybind = Enum.KeyCode.G,
Name = "Parade Rest",
ToolNames = {"Drill Rifle"},
},
}
return module
MotorHandler:
local tool = script.Parent
tool.Equipped:Connect(function()
if tool.MainPart.Motor6D.Part0 == nil then
tool.MainPart.Motor6D.Part0 = tool.Parent["Right Arm"]
end
end)
LocalScript
local uis = game:GetService("UserInputService")
local lPlayer = game:GetService("Players").LocalPlayer
local char = lPlayer.Character or lPlayer.CharacterAdded:Wait()
local animations = require(game.ReplicatedStorage:WaitForChild("DrillWeapons"):WaitForChild("Settings"))
local tool = script.Parent
local animTrackTable = {}
local playingAnim = nil
local canSwitchAnim = true
for i, animData in ipairs(animations) do
if table.find(animData.ToolNames, tool.Name) then
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://"..animData.AnimationID
local track = char:WaitForChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(anim)
animTrackTable[animData.Keybind.Name] = {track,i}
end
end
local ui = nil
tool.Equipped:Connect(function()
if tool.MainPart.Motor6D.Part0 == nil then
tool.MainPart.Motor6D:GetPropertyChangedSignal("Part0"):Wait()
end
if ui == nil then
ui = game.ReplicatedStorage.DrillWeapons.KeybindList:Clone()
ui.Parent = lPlayer.PlayerGui
for _, animData in pairs(animations) do
if table.find(animData.ToolNames, tool.Name) then
local sample = ui.MainFrame.ScrollingFrame.Sample:Clone()
sample.Name = animData.Name
sample.Parent = ui.MainFrame.ScrollingFrame
sample.TextLabel.Text = animData.Name..": "..animData.Keybind.Name
sample.Visible = true
end
end
else
ui.Enabled = true
end
for _, anim in pairs(animTrackTable) do
if anim[2] == 1 then
anim[1]:Play()
playingAnim = anim[1]
break
end
end
end)
tool.Unequipped:Connect(function()
playingAnim:Stop()
playingAnim = nil
canSwitchAnim = true
ui.Enabled = false
end)
local track = nil
uis.InputBegan:Connect(function(input, typing)
if typing == true then return end
if tool.Parent == char and canSwitchAnim == true then
if animTrackTable[input.KeyCode.Name] ~= nil then
track = animTrackTable[input.KeyCode.Name][1]
playingAnim:Stop()
playingAnim = nil
track:Play()
playingAnim = track
if track.Looped == false then
local currentTrack = track
canSwitchAnim = false
while tool.Parent == char and track.TimePosition < track.Length*.99 do -- only reliable way with roblox animations :/ (getpropertychangedsignal doesn't work)
task.wait()
end
if tool.Parent == char then
track:AdjustSpeed(0)
end
canSwitchAnim = true
end
end
end
end)
The first 3 work fine but the 4th one which is my custom animation plays the animation but the rifle is rotated weirdly on the arm
Normal Animations:
My custom animation:
How i want it:
Any help is appreciated