Humanoid unknown?

I am trying to make a melee attack, using an invisible image button covering the screen, and a click detector script.

Writing my local script, it says humanoid is unknown. Here is my local script:

local animation = Humanoid:LoadAnimation(script.Parent.Uppercut)

script.Parent.MouseButton1Click:Connect(function()
animation:Play()
end

Of course in studio “Humanoid” is underlined red.

I have checked the dev forum and education.roblox.com and found no solutions. Any help is appreciated. :grin:

1 Like

That’s because you didn’t write what is Humanoid, since it’s a LocalScript, you could get Humanoid like this:

local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:FindFirstChild("Humanoid")

I hope this helps you.

while it would read that because from the code I see there is no humanoid variable and it is just an empt variable

Oh, i didn’t know local scripts didn’t come with humanoid. Thanks so much!

Having a humanoid randomly defined like that, the script will be like “huh who”
You must always define the player’s humanoid so script knows who to mess with.

1 Like