This is the error that im getting:
This is the line of script that the error is emphasising on
local animationtrack = character:FindFirstChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(randomanimation)
This is my full script
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local userinputservice = game:GetService("UserInputService")
local replicatedstorage = game:GetService("ReplicatedStorage")
local cas = game:GetService("ContextActionService")
local punchkey = Enum.KeyCode.F
local debounce = 1
local animationfolder = script.animations:GetChildren()
local canpunch = true
local function punch()
local Tool = character:FindFirstChildWhichIsA("Tool")
if Tool then return end
if canpunch == true then
local randomanimation = animationfolder[math.random(1, #animationfolder)]
local animationtrack = character:FindFirstChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(randomanimation)
replicatedstorage.events.punchevent:FireServer()
animationtrack:Play()
canpunch = false
wait(debounce)
canpunch = true
end
end
userinputservice.InputBegan:Connect(function(input, busy)
if input.KeyCode == punchkey and not busy then
punch()
end
end)
cas:BindAction("Punch", punch, true, punchkey)
cas:SetPosition("Punch", UDim2.new(.4, .0, .1, 0))
cas:SetTitle("Punch", "Punch")
cas:GetButton("Punch").Size = UDim2.new(.3, 0, .3, 0)
i dont know if its a studio bug or just me being bad at scripting.