Essentially my animation won’t play when I press C to crouch…
I wanted to know if this was a script error and not something wrong with the animation
In StarterCharacterScripts:
repeat game:GetService("RunService").Stepped:wait() until game.Players.LocalPlayer
local player = script.Parent.Parent.Parent
local mouse = player:GetMouse()
local r = player.Character.Humanoid.RigType
local animator = Instance.new("Animator",player.Character.Humanoid)
humchanged = false
mouse.KeyDown:connect(function(key)
if key == "c" then
if player.Character.HumanoidRootPart.CanCollide == true then
player.Character.HumanoidRootPart.CanCollide = false
humchanged = true
end
R1AnimationId = "18328784670"
R2AnimationId = "18328784670"
local Anim = Instance.new("Animation")
if r == Enum.HumanoidRigType.R15 then
Anim.AnimationId = "rbxassetid://"..R1AnimationId
else
Anim.AnimationId = "rbxassetid://"..R2AnimationId
end
local k = animator:LoadAnimation(Anim)
k:Play()
k:AdjustSpeed(1)
end
end)
mouse.KeyUp:connect(function(key)
if key == "c" then
if humchanged then
player.Character.HumanoidRootPart.CanCollide = true
humchanged = false
end
tracks = animator:GetPlayingAnimationTracks()
for _,x in pairs(tracks)
do x:Stop()
end
end
end)