Hello! I made a crouch script that is a LocalScript in StarterCharacterScripts but it isn’t working… does anything look wrong with this script?
local player = game.Players.LocalPlayer
local UIS = game:GetService(“UserInputService”)
local Animate
local Humanoid = player.Character:FindFirstChild(‘Humanoid’)
UIS.InputBegan:Connect(function(Key,chat)
if chat then print(“Chat”) return end
if Key.KeyCode == Enum.KeyCode.C then
print(“Clicked C”)
local Animation = Instance.new(“Animation”, player.Character)
Animation.AnimationId = “rbxassetid://6929242508”
Animate = Humanoid:LoadAnimation(Animation)
Animate:Play()
Humanoid.WalkSpeed = Humanoid.WalkSpeed - 9
end
end)
UIS.InputEnded:Connect(function(Key,chat)
if chat then print(“Chat”) return end
if Key.KeyCode == Enum.KeyCode.C then
Animate:Stop()
Humanoid.WalkSpeed = 16
end
end)
I am also using a custom character, not sure if that would affect it. It won’t even print anything though, not even an error, that’s why I’m confused…
I just did this script on a normal R6 character and it prints crouching. I am unsure if this is an issue with the script. Animation Priority is probably it.
As you can see the Action priority has the highest priority while playing so the walking animation is set to Action (if i remember correctly) so it is played before your crouch animation because it has a highest priority.
Oh thank you, I will try this. The thing that confuses me the most is that it won’t print anything… I feel that if the script is right that it should at least print “Clicked C”. But, I will try changing the priority.
If its not printing “Clicked C” then you have something in ContextActionService binded to that key. This means the check to make sure chat is false is returning instead of proceeding with the rest of the thread.
Is it possible the script is being destroyed at all? I honestly have no clue as to why is wouldn’t be working. You could have a script that is destroying anything in the character.
This is true, however the animation is not working in general. Even with it being created only once. When I ran this code on my normal blank world with an R6 character it worked perfectly. There must be an external script interfering.
I’m sorry, just figured it out. I had a conflicting script. At the time I created the game, I didn’t know that you could use a rig by naming it StarterCharacter and putting it in StarterPlayer. So I created this complicated script that gave the player a character every respawn. I apologize for my mistake.