Animations Bug/Problem

Hello,
why is my “Equip A10” animation not completely overriding the march animation?

By the way, the “Equip_A10” is “Action” and Walk “Core”.

Combined: https://gyazo.com/09bacd45eb3b168df21c3e0644ff9821

Walk Animation:


https://gyazo.com/01089b734a97b365e13ca77322886962

A10 Equip Animation:

Animate script (for walk, sprint and pause animations):

local rf = game:GetService("ReplicatedFirst")
local rs = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")

local plr = game:GetService("Players").LocalPlayer
local character = script.Parent

local humanoid = character:FindFirstChild("Humanoid")

local walkAnim = script:WaitForChild("Walk")
local pauseAnim = script:WaitForChild("Pause")
local sprintAnim = script:WaitForChild("Sprint")
local walkAnimTrack = humanoid.Animator:LoadAnimation(walkAnim)
local pauseAnimTrack = humanoid.Animator:LoadAnimation(pauseAnim)
local sprintAnimTrack = humanoid.Animator:LoadAnimation(sprintAnim)

UIS.InputBegan:Connect(function(keycode, _gameProcess)
	if humanoid.MoveDirection ~= Vector3.new(0, 0, 0)then
		if keycode.KeyCode == Enum.KeyCode.LeftShift and not _gameProcess then
			if humanoid:FindFirstChild("Sprint") then  humanoid:FindFirstChild("Sprint").Value = true
			else 
				local v = Instance.new("BoolValue", character:FindFirstChildOfClass("Humanoid"))
				v.Name = "Sprint"
				v.Value = true
			end

			walkAnimTrack:Stop()
			sprintAnimTrack:Play()
			humanoid.WalkSpeed = 25
		end
	end
end)
UIS.InputEnded:Connect(function(keycode, _gameProcess)
	if humanoid.MoveDirection ~= Vector3.new(0, 0, 0) then
		if keycode.KeyCode == Enum.KeyCode.LeftShift and not _gameProcess then
			humanoid:FindFirstChild("Sprint").Value = false
			sprintAnimTrack:Stop()
			walkAnimTrack:Play()
			humanoid.WalkSpeed = 16
		end
	end
end)

humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
	if humanoid.MoveDirection == Vector3.new(0, 0, 0) then
		if walkAnimTrack.IsPlaying then
			walkAnimTrack:Stop()
		end

		if sprintAnimTrack.IsPlaying then
			sprintAnimTrack:Stop()
		end

		if not pauseAnimTrack.IsPlaying then
			pauseAnimTrack:Play()
		end
	else 
		--local getSprint = rs.Events.Movement.GetSprint:InvokeServer()
		local getSprint = humanoid:FindFirstChild("Sprint")
		if pauseAnimTrack.IsPlaying then
			pauseAnimTrack:Stop()
		end

		if getSprint and getSprint.Value then 
			if walkAnimTrack.IsPlaying then
				walkAnimTrack:Stop()
			end

			if not sprintAnimTrack.IsPlaying then
				sprintAnimTrack:Play()
			end
		else 
			if sprintAnimTrack.IsPlaying then
				sprintAnimTrack:Stop()
			end

			if not walkAnimTrack.IsPlaying then
				walkAnimTrack:Play()
			end
		end
	end
end)

Localscripts for A10:
image

  • Block:
local uis = game:GetService("UserInputService")
local rs = game:GetService("ReplicatedStorage")

local plr = game:GetService("Players").LocalPlayer

local function stopAnimations(char)
	local tracks = char:FindFirstChild("Humanoid"):FindFirstChildOfClass("Animator"):GetPlayingAnimationTracks()
	for i,v in pairs(tracks) do 
		if v.Name == "Equip_A10" then
			v:Stop()
		elseif v.Name == "Block_A10" then
			v:Stop()
		elseif v.Name == "Reload_A10" then
			v:Stop()
		elseif v.Name == "Shoot_A10" then
			v:Stop()
		end
	end
end

local tool = script.Parent

tool.Equipped:Connect(function()
	uis.InputBegan:Connect(function(code, _gp)
		if code.KeyCode == Enum.KeyCode.F and not _gp then
			local humanoid = plr.Character:FindFirstChildOfClass("Humanoid")
			if humanoid and rs.Events.Items.GetA10CanShoot:InvokeServer() then 
				stopAnimations(plr.Character)
				humanoid:FindFirstChildOfClass("Animator"):LoadAnimation(script.Block_A10):Play()
				rs.Events.Items.SetA10CanShoot:FireServer(false)
			end
		end
	end)

	uis.InputEnded:Connect(function(code, _gp)
		if code.KeyCode == Enum.KeyCode.F and not _gp then
			local humanoid = plr.Character:FindFirstChildOfClass("Humanoid")
			if humanoid and not rs.Events.Items.GetA10CanShoot:InvokeServer() then 
				stopAnimations(plr.Character)
				rs.Events.Items.SetA10CanShoot:FireServer(true)
				humanoid:FindFirstChildOfClass("Animator"):LoadAnimation(script.Equip_A10):Play()
			end
		end
	end)
end)
  • Reload
local ContextActionService = game:GetService("ContextActionService")
local rs = game:GetService("ReplicatedStorage")
local ACTION_RELOAD = "Reload"

local plr = game:GetService("Players").LocalPlayer
local tool =script.Parent

tool.Equipped:Connect(function()
	local function handleAction(actionName, inputState, _inputObject)
		if actionName == ACTION_RELOAD and inputState == Enum.UserInputState.Begin then
			local canShoot = rs.Events.Items.GetA10CanShoot:InvokeServer()
			if canShoot then 
				rs.Events.Items.A10Reload:FireServer()
			end
		end
	end

	ContextActionService:BindAction(ACTION_RELOAD, handleAction, true, Enum.KeyCode.R)
end)
  • Shoot :
local plr = game:GetService("Players").LocalPlayer
local mouse = plr:GetMouse()
local rs = game:GetService("ReplicatedStorage")

local tool = script.Parent
local pressing = false

local ColorAmmo = Instance.new("BrickColorValue", tool)
ColorAmmo.Value = BrickColor.new("Electric blue")

local DamageAmmo = Instance.new("IntValue", tool)
DamageAmmo.Value = 20

local function CreateBullet(nameGun, pos, dmg, col, origplr)
	if pressing then 
		local char = origplr.Character
		local gun = char:FindFirstChild(nameGun)
		local cp = gun:FindFirstChild("ShootPos").CFrame.p
		local ray = Ray.new(cp, (pos - cp).unit * 300)
		local part, position = workspace:FindPartOnRay(ray, char, false, true)

		local beam = Instance.new("Part", workspace)
		beam.BrickColor = col
		beam.FormFactor = "Custom"
		beam.Material = Enum.Material.Neon
		beam.Transparency = 0.8
		beam.Anchored = true
		beam.Locked = true
		beam.CanCollide = false

		local distance = (gun:FindFirstChild("ShootPos").CFrame.p - position).magnitude
		beam.Size = Vector3.new(0.04, 0.04, distance)
		beam.CFrame = CFrame.new(cp, position) * CFrame.new(0, 0, -distance / 2)

		rs.Events.Items.Shoot:FireServer("A10", mouse.Hit.p, DamageAmmo.Value, ColorAmmo.Value, part)

		game:GetService("Debris"):AddItem(beam, 0.05)
	end
end

tool.Equipped:Connect(function()
	local function handleAction()
		pressing = true
		local char = plr.Character
		if char then 
			local humanoid = char:FindFirstChildOfClass("Humanoid")
			local isEquipped = char:FindFirstChild("A10")
			if humanoid and isEquipped then
				while pressing do 
					local canShoot = rs.Events.Items.GetA10CanShoot:InvokeServer()
					local isReloading = rs.Events.Items.GetA10Reloading:InvokeServer()
					if canShoot and not isReloading then
						--rs.Events.Items.ARIShoot:FireServer(pressing) -- Animation
						humanoid:FindFirstChildOfClass("Animator"):LoadAnimation(script.Shoot_A10):Play()
						CreateBullet("A10", mouse.Hit.p, DamageAmmo.Value, ColorAmmo.Value, plr)
						task.wait(0.5)
					end
				end
			end
		end
	end

	rs.Events.Items.Shoot.OnClientEvent:Connect(function(rename, repos, redmg, reammo, replr)
		CreateBullet(rename, repos, redmg, reammo, replr)
	end)

	mouse.Button1Down:Connect(handleAction)
	mouse.Button1Up:Connect(function()
		pressing = false
	end)
end)
1 Like

I do not know if it can come from the character.

What exactly are you trying to do?

Do you want the equip animation to overwrite the walk animation completely?

Yes, I want to have my arms not moving like if it was the walk animation, normally arms should not move when I play the A10 Equip Animation.

I notice that the equip animation is not looped, but if that doesn’t fix, can you send a copy of the place so i can investigate it and try to solve it for you?

Well I will give you but I will remove some works of my studio to avoid problems.

Just before I will try something: get my old character and see if it comes from the character

Well did not fix… Sending you soon.

Eletroz found the problem, it comes from the character: there is a elbow and in walk animation, the elbow is animated but not in others animations.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.