I am trying to implement an attack in my game which involves the cloning and inserting of a shotgun model into the character. Inserting the model and setting up the Motor6Ds work, however for some reason the animation glitches and plays parts of the idle or walk animation. This happens even though the animation priority of the attack is Action, which is higher priority than the idle and walk animations. The shotgun model also isn’t deleted after the animation completes.
This problem just started a few hours ago. Before that it worked as intended.
I have had this issue in the past with another game however I never really discovered why the problem occurs as my solution was to just make a new place.
local animator = hum:WaitForChild("Animator")
local SHIFT_START_id = Instance.new("Animation")
SHIFT_START_id.AnimationId = "rbxassetid://12879653023"
local SHIFT_SHOT_id = Instance.new("Animation")
SHIFT_SHOT_id.AnimationId = "rbxassetid://12879651530"
local SHIFT_START_loaded = animator:LoadAnimation(SHIFT_START_id)
local SHIFT_SHOT_loaded = animator:LoadAnimation(SHIFT_SHOT_id)
SHIFT_START_loaded:Play()
local eventCon
eventCon = SHIFT_START_loaded:GetMarkerReachedSignal("shotgun"):Connect(function()
eventCon:Disconnect()
genMod.addJointed(plr, shotgun)
end)
local con
con = SHIFT_START_loaded.Stopped:Connect(function()
con:Disconnect()
print("begin recoil")
task.wait(0.1)
SHIFT_SHOT_loaded:Play(0)
local finCon
finCon = SHIFT_SHOT_loaded.Stopped:Connect(function()
finCon:Disconnect()
print("delete shotgun")
chr:FindFirstChild("double_barrel"):Destroy()
chr["Left Arm"]:WaitForChild("handle"):Destroy()
end)
genMod.playSound(SHIFT_SOUND.SoundId, SHIFT_SOUND.Volume, root)
for _,offset in pairs(offsetTable) do
local dmgTable = {}
local o = root.CFrame * CFrame.new(-0.641, 0.525, -3.175) * CFrame.Angles(0, math.rad(-10.542), math.rad(-180))
o *= offset
local d = o.LookVector * 11
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Blacklist
params.FilterDescendantsInstances = {chr, workspace["Projectiles"], workspace["Followers"], workspace["Explosions"]}
debugMod.visualiseRaycast(o.Position, d)
local result = workspace:Raycast(o.Position, d, params)
if result then
local i = result.Instance
local p = i.Parent
if i and not dmgTable[p] then
dmgTable[p] = true
local h = p:FindFirstChildWhichIsA("Humanoid")
if h then
damageEvent:FireServer(p, 5)
end
end
end
end
local lv = Instance.new("LinearVelocity")
lv.RelativeTo = Enum.ActuatorRelativeTo.World
lv.MaxForce = 49999
lv.VectorVelocity = -root.CFrame.LookVector * 75 + Vector3.new(0, 15, 0)
lv.Attachment0 = root:WaitForChild("RootAttachment")
lv.Parent = root
game:GetService("Debris"):AddItem(lv, 0.2)
hum.WalkSpeed = 16
CURRENT_ACTION = not CURRENT_ACTION
guiModule.CD_FADE(plr, "SHIFT", 5)
task.wait(5)
SHIFT_DEBOUNCE = not SHIFT_DEBOUNCE
end)
end