Why is this not working?

i maked a crouch script and its not working

local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Animation = script:WaitForChild("Animation", 10)
local Character = Player.Character or Player.CharacterAdded:Wait()
local crouch = false
local Track = Character:FindFirstChild("Humanoid"):LoadAnimation(Animation)
UIS.InputBegan:Connect(function(Input, GameProcessed) 
	
	
	if Input.KeyCode == Enum.KeyCode.C then 
		Track.Priority = Enum.AnimationPriority.Movement
		if crouch== false then
			Track.Looped = true
			Track:Play()
			
			crouch= true
		end
		if crouch== true then
			Track:Stop()
			crouch = false
		end
	end
end)

2 Likes

Use Animator:LoadAnimation().

iam tried still not working :frowning:
roblox min length

Can you show the script? Also, please make sure you are coding this in a local script.

Is there any errors in the output?

no i dont get any error in the output

I think it has something to do with the animation’s priority. Try setting it to Action. If that doesn’t work, try to make sure each part of the script inside the event runs. Make sure the script is running through the conditional statements so that you know which part of the script is running.

1 Like