So I was animating on Blender and when I test it out there is no default animation when I equip but it can only work by using Moon Animator 2 if there is default animation but I been trying to fixed it but I couldn’t so yeah.
show us the script your using. you posted this in scripting support.
local handle = tool:WaitForChild("Handle")
local idleAnimationId = "rbxassetid://18714698890"
local shootAnimationId = "rbxassetid://18714608628"
local reloadAnimationId = "rbxassetid://18715722006"
local inspectAnimationId = "rbxassetid://18709863942"
local animator
local idleAnimation
local shootAnimation
local reloadAnimation
local inspectAnimation
local idleTrack
local shootTrack
local reloadTrack
local inspectTrack
local bolt = handle:WaitForChild("Bolt")
local mag = handle:WaitForChild("Mag")
local slide = handle:WaitForChild("Slide")
local barrel = handle:WaitForChild("Barrel")
local build = handle:WaitForChild("Build")
local circle = handle:WaitForChild("Circle")
local defend = handle:WaitForChild("Defend")
local muzzle = handle:WaitForChild("Muzzle")
local click = handle:WaitForChild("Click")
local line = handle:WaitForChild("Line")
local stock = handle:WaitForChild("Stock")
local optic = handle:WaitForChild("Optic")
local sighter = handle:WaitForChild("Sighter")
local defender = handle:WaitForChild("Defender")
local firePart = handle:WaitForChild("Fire")
local shootSound = firePart:FindFirstChild("ShootSound")
local muzzleEffect = firePart:FindFirstChild("MuzzleEffect")
local reloadSound = handle:FindFirstChild("ReloadSound")
local magInSound = handle:FindFirstChild("MagInSound")
local magOutSound = handle:FindFirstChild("MagOutSound")
local boltSound = handle:FindFirstChild("BoltSound")
local slideSound = handle:FindFirstChild("SlideSound")
local clickSound = handle:FindFirstChild("ClickSound")
local trailEffect = firePart:FindFirstChild("TrailEffect")
local canFire = true
local fireRate = 0.01
local lastShotTime = 0
local semiCooldown = 0.1
local bulletDamage = 20
local spreadAngle = 2
local maxAmmo = 30
local currentAmmo = maxAmmo
local reloadTime = 3
local isReloading = false
local isEquipped = false
local isInspecting = false
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BulletHitEvent = ReplicatedStorage:WaitForChild("BulletHitEvent")
local ammoHUD = tool:WaitForChild("AmmoHUD")
local currentAmmoLabel = ammoHUD:WaitForChild("CurrentAmmo")
local function AmmoDisplay()
if currentAmmoLabel then
currentAmmoLabel.Text = "Ammo: " .. tostring(currentAmmo) .. " / " .. tostring(maxAmmo)
end
end
local function preloadAnimation(animationId)
local animation = Instance.new("Animation")
animation.AnimationId = animationId
local animator = tool.Parent:FindFirstChildOfClass("Humanoid"):FindFirstChildOfClass("Animator")
local animationTrack = animator:LoadAnimation(animation)
animationTrack:Play()
animationTrack:Stop()
return animation
end
local function playIdleAnimation()
if animator and idleAnimation then
if idleTrack then
idleTrack:Stop()
end
idleTrack = animator:LoadAnimation(idleAnimation)
idleTrack:Play()
end
end
local function stopIdleAnimation()
if idleTrack then
idleTrack:Stop()
idleTrack = nil
end
end
local function playShootAnimation()
if animator and shootAnimation then
if shootTrack then
shootTrack:Stop()
end
shootTrack = animator:LoadAnimation(shootAnimation)
shootTrack.Priority = Enum.AnimationPriority.Action
shootTrack:Play()
end
end
local function onReloadAnimationEnd()
if isEquipped then
playIdleAnimation()
end
end
local function playReloadAnimation()
if animator and reloadAnimation then
if reloadTrack then
reloadTrack:Stop()
print("Stopped previous reload animation track")
end
reloadTrack = animator:LoadAnimation(reloadAnimation)
reloadTrack.Priority = Enum.AnimationPriority.Action
reloadTrack.Stopped:Connect(function()
print("Reload animation stopped")
onReloadAnimationEnd()
end)
print("Playing reload animation")
reloadTrack:Play()
end
end
local function onInspectAnimationEnd()
isInspecting = false
if isEquipped then
playIdleAnimation()
end
end
local function playInspectAnimation()
if animator and inspectAnimation then
if inspectTrack then
inspectTrack:Stop()
print("Stopped previous inspect animation track")
end
if idleTrack then
idleTrack:Stop()
end
inspectTrack = animator:LoadAnimation(inspectAnimation)
inspectTrack.Priority = Enum.AnimationPriority.Action
inspectTrack.Stopped:Connect(function()
print("Inspect animation stopped")
onInspectAnimationEnd()
end)
print("Playing inspect animation")
inspectTrack:Play()
end
end
local function initAnimations(character)
local humanoid = character:WaitForChild("Humanoid")
animator = humanoid:FindFirstChildOfClass("Animator") or humanoid:WaitForChild("Animator")
idleAnimation = Instance.new("Animation")
idleAnimation.AnimationId = idleAnimationId
shootAnimation = Instance.new("Animation")
shootAnimation.AnimationId = shootAnimationId
reloadAnimation = Instance.new("Animation")
reloadAnimation.AnimationId = reloadAnimationId
inspectAnimation = Instance.new("Animation")
inspectAnimation.AnimationId = inspectAnimationId
end
tool.Equipped:Connect(function()
isEquipped = true
local player = game.Players:GetPlayerFromCharacter(tool.Parent)
if player then
local character = player.Character or player.CharacterAdded:Wait()
initAnimations(character)
playIdleAnimation()
idleAnimation = preloadAnimation(idleAnimationId)
shootAnimation = preloadAnimation(shootAnimationId)
reloadAnimation = preloadAnimation(reloadAnimationId)
inspectAnimation = preloadAnimation(inspectAnimationId)
ammoHUD.Parent = player:WaitForChild("PlayerGui")
AmmoDisplay()
end
end)
tool.Unequipped:Connect(function()
isEquipped = false
stopIdleAnimation()
if reloadTrack then
reloadTrack:Stop()
reloadTrack = nil
end
if inspectTrack then
inspectTrack:Stop()
inspectTrack = nil
end
if magOutSound and magOutSound.IsPlaying then
magOutSound:Stop()
end
if reloadSound and reloadSound.IsPlaying then
reloadSound:Stop()
end
if magInSound and magInSound.IsPlaying then
magInSound:Stop()
end
if boltSound and boltSound.IsPlaying then
boltSound:Stop()
end
if slideSound and slideSound.IsPlaying then
slideSound:Stop()
end
if clickSound and clickSound.IsPlaying then
clickSound:Stop()
end
ammoHUD.Parent = tool
end)
local function handleDeath(humanoid)
if humanoid and humanoid.Health > 0 then
humanoid:TakeDamage(humanoid.Health)
end
end
local function onBulletHit(hit, bullet)
local character = hit.Parent
if character then
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
BulletHitEvent:FireServer(humanoid, bulletDamage)
end
end
bullet:Destroy()
end
local function setRandomPlaybackSpeed(sound)
if sound then
sound.PlaybackSpeed = math.random(95, 107) / 100
end
end
local function shoot()
local currentTime = tick()
if not canFire or isReloading or isInspecting or (currentTime - lastShotTime) < fireRate then return end
lastShotTime = currentTime
if currentAmmo > 0 then
canFire = false
currentAmmo = currentAmmo - 1
AmmoDisplay()
playShootAnimation()
local bullet = Instance.new("Part")
bullet.Shape = Enum.PartType.Ball
bullet.Size = Vector3.new(0.2, 0.2, 0.2)
bullet.CFrame = firePart.CFrame
bullet.Anchored = false
bullet.CanCollide = false
bullet.Parent = workspace
local velocity = Instance.new("BodyVelocity")
local spreadX = math.rad(math.random(-spreadAngle, spreadAngle))
local spreadY = math.rad(math.random(-spreadAngle, spreadAngle))
local spread = Vector3.new(spreadX, spreadY, 0)
local direction = (firePart.CFrame.LookVector + spread).unit
velocity.Velocity = direction * 250
velocity.Parent = bullet
if trailEffect then
local trail = trailEffect:Clone()
trail.Parent = bullet
local attachment0 = Instance.new("Attachment", bullet)
attachment0.Position = Vector3.new(0, 0, -bullet.Size.Z / 2)
attachment0.Parent = bullet
local attachment1 = Instance.new("Attachment", bullet)
attachment1.Position = Vector3.new(0, 0, bullet.Size.Z / 2)
attachment1.Parent = bullet
trail.Attachment0 = attachment0
trail.Attachment1 = attachment1
end
bullet.Touched:Connect(function(hit)
if hit:IsDescendantOf(tool.Parent) then
return
end
onBulletHit(hit, bullet)
end)
game.Debris:AddItem(bullet, 5)
setRandomPlaybackSpeed(shootSound)
if shootSound then
shootSound:Play()
end
if muzzleEffect then
muzzleEffect.Enabled = true
wait(0.05)
muzzleEffect.Enabled = false
end
else
setRandomPlaybackSpeed(clickSound)
if clickSound then
clickSound:Play()
end
end
wait(fireRate)
canFire = true
end
local function startShooting()
while isEquipped and not isReloading and not isInspecting and UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) do
shoot()
wait(fireRate)
end
end
local function reload()
if not isEquipped or isReloading or isInspecting or currentAmmo >= maxAmmo then return end
isReloading = true
canFire = false
stopIdleAnimation()
playReloadAnimation()
local function playReloadSounds()
if magOutSound then
wait(0.4)
setRandomPlaybackSpeed(magOutSound)
magOutSound:Play()
wait(magOutSound.TimeLength)
end
AmmoDisplay()
if reloadSound then
wait()
setRandomPlaybackSpeed(reloadSound)
reloadSound:Play()
wait(reloadSound.TimeLength)
end
if magInSound then
wait(1)
setRandomPlaybackSpeed(magInSound)
magInSound:Play()
wait(magInSound.TimeLength)
currentAmmo = maxAmmo
AmmoDisplay()
end
wait(0.23)
if boltSound then
wait(0.15)
setRandomPlaybackSpeed(boltSound)
boltSound:Play()
wait(boltSound.TimeLength)
end
if slideSound then
wait()
setRandomPlaybackSpeed(slideSound)
slideSound:Play()
wait(slideSound.TimeLength)
end
end
coroutine.wrap(playReloadSounds)()
print("Reloading!")
wait(reloadTime)
isReloading = false
canFire = true
end
tool.Activated:Connect(function()
local currentTime = tick()
if currentTime - lastShotTime >= semiCooldown then
lastShotTime = currentTime
startShooting()
end
end)
tool.Deactivated:Connect(function()
canFire = true
end)
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.R and not gameProcessed then
reload()
end
if input.KeyCode == Enum.KeyCode.H and not gameProcessed then
if not isInspecting and isEquipped and not isReloading then
isInspecting = true
playInspectAnimation()
end
end
end)