Hello, i use this function for my gun run system. But for some reason if you press shift your game freezes for 0.5s
Any ideas why?
local animation1
local animation2
local function GunRun(PlayOrStop)
if Character:FindFirstChildWhichIsA("Tool") then
local v = Character:FindFirstChildWhichIsA("Tool")
if v:FindFirstChild("Animations") and not animation2 then
animation2 = Humanoid:LoadAnimation(v:FindFirstChild("Animations").Run)
end
if PlayOrStop == "Play" then
if v:FindFirstChild("Animations") then
if v:FindFirstChild("Animations").Run and animation2 and not animation2.IsPlaying then
animation2:Play()
end
end
v.Unequipped:Connect(function()
if v:FindFirstChild("Animations") then
if v:FindFirstChild("Animations").Run and animation2 then
animation2:Stop()
animation2 = nil
end
end
end)
elseif PlayOrStop == "Stop" then
if v:FindFirstChild("Animations") then
if v:FindFirstChild("Animations").Run and animation2 then
animation2:Stop()
animation2 = nil
end
end
end
end
end