Ok, so I am getting so many errors! And I need hep to ix the code can anybody help?
Error:
14:09:13.553 - local player = game.Players.LocalPlayer
14:09:13.553 -
14:09:13.554 - local userInputService = game:GetService("UserInputService")
14:09:13.555 -
14:09:13.555 - local animationID = "rbxassetid://5149640147"
14:09:13.556 -
14:09:13.556 - local animPlaying = false
14:09:13.557 -
14:09:13.558 - function crouch()
14:09:13.558 - if player:FindFirstChild("Contestant") then
14:09:13.559 - if animPlayin:43: attempt to index nil with 'Parent'
Code:
local player = game.Players.LocalPlayer
local userInputService = game:GetService("UserInputService")
local animationID = "rbxassetid://5149640147"
local animPlaying = false
function crouch()
if player:FindFirstChild("Contestant") 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
local userInputService = game:GetService("UserInputService")
userInputService.InputBegan:Connect(function(input,gpe)
if input.KeyCode == Enum.KeyCode.LeftControl then
print("Correct input")
crouch()
end
end)
script.Parent:WaitForChild("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)
I'm new to scripting so please help :(

2 comments
Can you show us the line where the error originates?
line 43