Hello! I've been trying for a bit to get this dang issue from happening. Here is the script I am using, this is in StarterCharacterScripts. Also, this is a Local Script, and I have two Remote Events in ReplicatedStorage, and two Server Scripts in ServerScriptService. Hope you can figure out whats going on! -Mrmonkeyman120
local tool = game.StarterPack.M4
local db = true
local UserInputService = game:GetService('UserInputService')
local anim = Instance.new("Animation")
anim.AnimationId = 'https://www.roblox.com/asset/?id=3345626311'
local playAnim = game.Players.LocalPlayer.Character:WaitForChild("Humanoid"):LoadAnimation(anim)
game.ReplicatedStorage.ShiftToSprintHoldGun:FireServer()
UserInputService.InputBegan:Connect(function(input, event)
if input.KeyCode == Enum.KeyCode.LeftShift and db then
db = false
if tool.Equipped then
playAnim:Play()
db = true
end
end
end)
if tool.Unequipped then
local Anim = Instance.new("Animation")
Anim.AnimationId = 'https://www.roblox.com/asset/?id=3345452716'
local playanim = game.Players.LocalPlayer.Character:WaitForChild("Humanoid"):LoadAnimation(Anim)
game.ReplicatedStorage.ShiftToSprintHoldGun:FireServer()
UserInputService.InputBegan:Connect(function(input, Event)
if input.KeyCode == Enum.KeyCode.LeftShift and db then
db = false
playAnim:Stop()
wait(0.15)
playanim:Play()
print("Worked")
end
end)
end

1 comment
in my script line 1, change it to local tool = game.Players.LocalPlayer.Backpack:FindFirstChild("M4") or game.Players.LocalPlayer.Character:FindFirstChild("M4")