Different Sprint Animation with Tool

Hey, so I’ve been trying to figure out a way to make a separate running animation with and without a specific gun is equipped, similar to criminality and entrenched.

I’ve tried to make an if statement but only broke the script with an astronomical amount of errors, I’ve tried to put the a separate duplicate in the gun/tool without the things already on the original script without any luck.

heres my sprint script.

local UIS = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
local Character = Player.Character

UIS.InputBegan:connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then 
		Player.PlayerScripts.StancesScript.Disabled = true
		workspace.CurrentCamera.FieldOfView = 100
		Character.Humanoid.WalkSpeed = 25
		local Anim = Instance.new('Animation')
		Anim.AnimationId = 'rbxassetid://7631432785'
		PlayAnim = Character.Humanoid:LoadAnimation(Anim)
		PlayAnim:Play()
		
	end
end)

UIS.InputEnded:connect(function(input)	
	if input.KeyCode == Enum.KeyCode.LeftShift then
		Player.PlayerScripts.StancesScript.Disabled = false
		Character.Humanoid.WalkSpeed = 16
		PlayAnim:Stop()
	end
end)

Any help will be strongly appreciated.

Is StancesScript local or server?

thats about a different script but its local i believe.

theres nothing wrong with the script its just im trying to figure out how to add a different sprint animation for a specific tool using that script

There isn’t much indication as to where in the script this should be added.

https://developer.roblox.com/en-us/api-reference/event/Tool/Equipped
https://developer.roblox.com/en-us/api-reference/event/Tool/Unequipped

Avoid reloading the same animation inside of a loop/function connected to a repetitively fired event.

local UIS = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild('Humanoid')

local Anim1 = Instance.new('Animation')
Anim1.AnimationId = 'rbxassetid://0'
PlayAnim1 = Humanoid:LoadAnimation(Anim1)

local Anim2 = Instance.new('Animation')
Anim2.AnimationId = 'rbxassetid://0'
PlayAnim2 = Humanoid:LoadAnimation(Anim2)

UIS.InputBegan:connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then 
		Player.PlayerScripts.StancesScript.Disabled = true
		workspace.CurrentCamera.FieldOfView = 100
		Character.Humanoid.WalkSpeed = 25
		if Character:FindFirstChild("Tool1") then --tool1 equipped
			PlayAnim1:Play()
		elseif Character:FindFirstChild("Tool2") then --tool2 equipped
			PlayAnim2:Play()
		else
			--no tool equipped
		end
	end
end)

UIS.InputEnded:connect(function(input)	
	if input.KeyCode == Enum.KeyCode.LeftShift then
		Player.PlayerScripts.StancesScript.Disabled = false
		Character.Humanoid.WalkSpeed = 16
		PlayAnim1:Stop()
		PlayAnim2:Stop()
	end
end)
1 Like

sorry for the late reply, but tysm you dont want to know how much ive been trying to find a solution for this