Hello there, thank you for reading this. I have been following AlivnBlox’s Piggy’s series/tutorials and everything works well! That is except for the crouching GUI/button. The button is designed to make the player’s walkspeed to 14 and make them have a crouch animation. So far I tested all the possibilities and the only part that works is the walkspeed to 14, while the animation doesn’t work. (I tried diffrent animations and they all didn’t work. Also is not because of R15 and R6 I tried that and is still broken.)
Anyways here’s teh script:
local player = game.Players.LocalPlayer
local userInputService = game:GetService(“UserInputService”)
local animationID = “rbxassetid://3323577844”
local animPlaying = false
function crouch()
if player:FindFirstChild(“Contestant”) then
if not player:FindFirstChild(“Stuck”) then
if animPlaying == false then
local animObj = Instance.new(“Animation”)
animObj.AnimationId = animationID
local loadedAnim = player.Character.Humanoid:LoadAnimation(animObj)
loadedAnim:Play()
player.Character.Humanoid.WalkSpeed = 10
animPlaying = true
script.Parent.Crouch.ImageColor3 = Color3.fromRGB(26, 144, 255)
script.Parent.Crouch.TextLabel.BackgroundColor3 = Color3.fromRGB(26, 144, 255)
print(“Playing”)
else
print(“Stopping”)
for i , v in pairs(player.Character.Humanoid:GetPlayingAnimationTracks()) do
v:Stop()
end
player.Character.Humanoid.WalkSpeed = 16
animPlaying = false
script.Parent.Crouch.ImageColor3 = Color3.fromRGB(255,255,255)
script.Parent.Crouch.TextLabel.BackgroundColor3 = Color3.fromRGB(255,255,255)
end
end
end
end
userInputService.InputBegan:Connect(function(input,gpe)
if input.KeyCode == Enum.KeyCode.LeftControl then
print(“Corect input”)
crouch()
end
end)
script.Parent.Crouch.MouseButton1Click:Connect(function()
crouch()
end)
game.ReplicatedStorage.ToggleCrouch.OnClientEvent:Connect(function(visiblity)
script.Parent.Crouch.Visible = visiblity
for i , v in pairs(player.Character.Humanoid:GetPlayingAnimationTracks()) do
v:Stop()
end
player.Character.Humanoid.WalkSpeed = 16
animPlaying = false
script.Parent.Crouch.ImageColor3 = Color3.fromRGB(255,255,255)
script.Parent.Crouch.TextLabel.BackgroundColor3 = Color3.fromRGB(255,255,255)
end)
Also here’s the explorer for people wondering