not sure why its doing this
local playidle,playwalk,playrun
local tool = script.Parent
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum:Humanoid = char:WaitForChild("Humanoid")
local ItemStats = require(game:GetService("ReplicatedStorage"):WaitForChild("Assets"):WaitForChild("Modules"):WaitForChild("ItemStats"))
local equipped = false
local idleid = Instance.new("Animation")
idleid.AnimationId = "rbxassetid://"..ItemStats[tool.Name]["Animations"]["Idle"]
local walkid = Instance.new("Animation")
walkid.AnimationId = "rbxassetid://"..ItemStats[tool.Name]["Animations"]["Walk"]
local runid
if ItemStats[tool.Name]["Animations"]["Run"] then
runid = Instance.new("Animation")
runid.AnimationId = "rbxassetid://"..ItemStats[tool.Name]["Animations"]["Run"]
end
tool.Equipped:Connect(function()
equipped = true
game:GetService("RunService").Stepped:Wait()
if not playidle then
playidle = hum:LoadAnimation(idleid)
playidle.Priority = Enum.AnimationPriority.Action
end
if not playwalk then
playwalk = hum:LoadAnimation(walkid)
playwalk.Priority = Enum.AnimationPriority.Movement
end
if runid and not playrun then
playrun = hum:LoadAnimation(runid)
playrun.Priority = Enum.AnimationPriority.Action2
end
task.spawn(function()
game:GetService("RunService").RenderStepped:Connect(function()
if equipped == true then
if hum.MoveDirection.Magnitude > 0 then
if playidle.IsPlaying then
playidle:Stop()
end
if not playwalk.IsPlaying then
playwalk:Play()
end
if hum.WalkSpeed > 14 and playrun then
playwalk:Stop()
if not playrun.IsPlaying then
playrun:Play()
end
end
if hum.WalkSpeed <= 14 then
if not playwalk.IsPlaying then
playwalk:Play()
end
if playrun and playrun.IsPlaying then
playrun:Stop()
end
end
else
if not playidle.IsPlaying then
playidle:Play()
end
if playwalk.IsPlaying then
playwalk:Stop()
end
if playrun and playrun.IsPlaying then
playrun:Stop()
end
end
end
end)
end)
end)
tool.Unequipped:Connect(function()
equipped = false
if playwalk.IsPlaying then
playwalk:Stop()
end
if playidle.IsPlaying then
playidle:Stop()
end
if runid and playrun.IsPlaying then
playrun:Stop()
end
end)