local Human = script.Parent:WaitForChild("Humanoid")
local UserInputService = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Character = Player.Character
UserInputService.InputBegan:connect(function(INP)
if INP.KeyCode == Enum.KeyCode.LeftControl then
Human.Running:Connect(function(speed)
if speed < 6 then
Character.Humanoid.WalkSpeed = 18.5
local Anim = Instance.new('Animation')
Anim.AnimationId = 'rbxassetid://5709810264'
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
PlayAnim:Play()
elseif speed > 6 then
UserInputService.InputEnded:connect(function(INP)
if INP.KeyCode == Enum.KeyCode.LeftControl then
Character.Humanoid.WalkSpeed = 7.5
PlayAnim:Stop()
end
end)
end
end)
end
end)
Hello!
You are trying to stop animation that does not exist instead of using
PlayAnim:Stop()
Use
for _,track in pairs(Character.Humanoid:GetPlayingAnimationTracks()) do -- Looping all playing tracks and stopping them
track:Stop()
end
Local IdleAni = Character.Humanoid:LoadAnimation(Character.Animate.idle.Animation1) -- This will loads players idle animation
IdleAni:Play()
local Human = script.Parent:WaitForChild("Humanoid")
local UserInputService = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Character = Player.Character
UserInputService.InputBegan:connect(function(INP)
if INP.KeyCode == Enum.KeyCode.LeftControl then
Human.Running:Connect(function(speed)
if speed < 6 then
Character.Humanoid.WalkSpeed = 18.5
local Anim = Instance.new('Animation')
Anim.AnimationId = 'rbxassetid://5709810264'
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
PlayAnim:Play()
elseif speed > 6 then
UserInputService.InputEnded:connect(function(INP)
if INP.KeyCode == Enum.KeyCode.LeftControl then
Character.Humanoid.WalkSpeed = 7.5
for _,track in pairs(Character.Humanoid:GetPlayingAnimationTracks()) do
track:Stop()
end
local IdleAni = Character.Humanoid:LoadAnimation(Character.Animate.idle.Animation1)
IdleAni:Play()
end
end)
end
end)
end
end)