I'm pretty unsure why I've been getting this error, I even printed it out and it returned Humanoid, so why am I getting this error?
01 | game.Players.LocalPlayer.Character:WaitForChild( "RightHand" ).Touched:Connect( function (hit) |
02 | if playAnim.IsPlaying then |
03 | print (hit.Parent:FindFirstChild( "Humanoid" )) |
04 | if hit.Parent:FindFirstChild( "Humanoid" ) and not debounce and not beenDamaged and hit.Parent ~ = player.Humanoid then |
05 | if player.Character.Humanoid.Health > 0 then |
06 | beenDamaged = true |
07 | replicatedStorage:WaitForChild( "Punch" ):FireServer(hit.Parent.Humanoid) |
08 | end |
09 | end |
10 | end |
11 | end ) |
When I first started learning Lua with Roblox, I did this all the time. Player refers to the actual player, while its child "Character" refers to the actual model in the Workspace. Because Humanoid is a child of the actual Character model, you cannot index it from "Player". So, to fix this, you would just change line 04 into: if hit.Parent:FindFirstChild("Humanoid") and not debounce and not beenDamaged and hit.Parent ~= player.Character then
The error message "Humanoid is not a valid member of Player" simply says "An object called Humanoid doesn't exist inside the Player" in more obvious English. Hope this answer helped :)