Hi! I am currently working on a melee system with the FE Melee Kit model. However, I ran into an issue. I have a sprinting system in the game. When I sprint with a Melee weapon equipped, it glitches out the arms (video) which I do not want. Is there anyway to make the running animation not effect the arms ONLY when a tool is equipped?
-- Settings
local sprintSpeed = 20
local defaultSpeed = 16
local sprintFov = 80
local normalFov = 70
local sprintKey = Enum.KeyCode.LeftShift
local sprintButton = Enum.KeyCode.ButtonL3
--// Services
-- External services
local userInputService = game:GetService("UserInputService")
local tweenService = game:GetService("TweenService")
local runService = game:GetService("RunService")
-- Internal services
local replicatedStorage = game:GetService("ReplicatedStorage")
local playersService = game:GetService("Players")
-- // Variables
-- Comms variables
local sprintEvent = replicatedStorage:WaitForChild("SprintEvent")
-- Player variables
local player = playersService.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local camera = workspace.CurrentCamera
-- Animation variables
local sprintAnim = script:WaitForChild("SprintAnim")
local sprintTrack = humanoid:LoadAnimation(sprintAnim)
-- Booleans
local sprinting = false
-- Functions
local function tweenFov(duration, fov)
local tween = tweenService:Create(camera, TweenInfo.new(duration, Enum.EasingStyle.Quad), {FieldOfView = fov})
tween:Play()
spawn(function()
tween.Completed:Wait()
tween:Destroy()
end)
end
-- // Events
-- Input handling
userInputService.InputBegan:Connect(function(input, processed)
if input.KeyCode == sprintKey and not processed then
if not sprinting then
sprinting = true
if humanoid.MoveDirection.Magnitude > 0 then
if not sprintTrack.IsPlaying then
sprintTrack:Play(0.25)
end
end
sprintEvent:FireServer(sprintSpeed)
tweenFov(0.35, sprintFov)
end
elseif input.KeyCode == sprintButton and not processed then
if sprinting then
sprinting = false
if sprintTrack.IsPlaying then
sprintTrack:Stop()
end
sprintEvent:FireServer(defaultSpeed)
tweenFov(0.35, normalFov)
else
sprinting = true
if humanoid.MoveDirection.Magnitude > 0 then
if not sprintTrack.IsPlaying then
sprintTrack:Play(0.25)
end
end
sprintEvent:FireServer(sprintSpeed)
tweenFov(0.35, sprintFov)
end
end
end)
userInputService.InputEnded:Connect(function(input)
if input.KeyCode == sprintKey then
sprinting = false
if sprintTrack.IsPlaying then
sprintTrack:Stop()
end
sprintEvent:FireServer(defaultSpeed)
tweenFov(0.35, normalFov)
end
end)
-- Animation handling
humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
if humanoid.FloorMaterial == Enum.Material.Air then
if sprinting then
repeat wait()
if sprintTrack.IsPlaying then
sprintTrack:Stop()
end
until humanoid.FloorMaterial ~= Enum.Material.Air
if sprinting then
if humanoid.MoveDirection.Magnitude > 0 then
if not sprintTrack.IsPlaying then
sprintTrack:Play(0.45)
end
end
else
sprinting = false
if sprintTrack.IsPlaying then
sprintTrack:Stop()
end
sprintEvent:FireServer(defaultSpeed)
tweenFov(0.35, normalFov)
end
end
else
if sprinting then
if humanoid.MoveDirection.Magnitude > 0 then
if not sprintTrack.IsPlaying then
sprintTrack:Play(0.25)
end
end
end
end
end)
humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
if humanoid.MoveDirection.Magnitude > 0 then
if sprinting then
if not sprintTrack.IsPlaying then
sprintTrack:Play(0.25)
end
end
end
end)
You can look into this forum post, but you need to load the animations on the Animator instead of the Humanoid for it to work. Plus, loading animations in Humanoids is deprecated in the first place.