Crouch Animation issues

Back to nothing. doesnt work, no output message.
This is so annoying bruh

Code:

local animID = 'rbxassetid://16232852979'
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Humanoid = player.CharacterAdded:Wait():FindFirstChild("Humanoid")
local activated = false
local UIS = game:GetService("UserInputService")

local animation = Instance.new("Animation")

animation.AnimationId = animID

local AnimationTrack = Humanoid:LoadAnimation(animation)

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.C then
		activated = not activated
		print(activated)
		if activated then AnimationTrack:Play() else AnimationTrack:Stop() end
	end
end)

d.lua (629 Bytes)
Put it in starterCharacterScripts

Still doesnt work. At this point Im thinking it has to be something with the animation, the script shows no indication of errors.

I’m thinking this is a animation issue. Could it be?

There actually was an error this time.

image

You don’t need to get player or mouse…

local animID = 'rbxassetid://16232852979'
local Humanoid = script.Parent:FindFirstChild("Humanoid")

if Humanoid then
	local activated = false
	local UIS = game:GetService("UserInputService")
	
	local animation = Instance.new("Animation")
	
	animation.AnimationId = animID
	
	local AnimationTrack = Humanoid:LoadAnimation(animation)
	
	UIS.InputBegan:Connect(function(input)
		if input.KeyCode == Enum.KeyCode.C then
			activated = not activated
			print(activated)
			if activated then AnimationTrack:Play() else AnimationTrack:Stop() end
		end
	end)
end

Still nothing.

asdhbasdasdaibsdiaugsd


132d6147d23047cec52e2f6132e19a40

wait(1)
local animID = 'rbxassetid://16066342156'
local Humanoid = script.Parent:FindFirstChild("Humanoid")

if Humanoid then
	local activated = false
	local UIS = game:GetService("UserInputService")

	local animation = Instance.new("Animation")

	animation.AnimationId = animID

	local AnimationTrack = Humanoid:LoadAnimation(animation)

	UIS.InputBegan:Connect(function(input)
		if input.KeyCode == Enum.KeyCode.C then
			activated = not activated
			print(activated)
			if activated then AnimationTrack:Play() else AnimationTrack:Stop() end
		end
	end)
end

Bruh what…

It doesnt work and there is literally not a single reason as to why.

My game is R6, made the animation in R6. Nothing works.
Thanks for your help but i think we’ve reached a dead end here.

This could be the result of a naming convention issue, are there any other errors within the output?

None. Not a single error, it just does nothing.
And when we did print(“click”) after the InputBegan function that didnt work either for some reason until i tried it in an alternate game where it did indeed print (“clicked”) but it still didnt wanna run the animation.

You need to set up a test plan for your game, do an erroneous, extreme and normal test each to determine whether the problem is studio related or a problem with your script.

Since the specificity of the problem is objectively on you, we can’t really do much but advise you to test everything properly as it’s a very isolated issue and as @ExercitusMortem said, he already tried it out himself.

I would highly recommend decomposition to test the integrity of your game as it seems like a very foundational problem.