My aplogies if the title is a bit confusing but I'll explain it the best I can. I wrote a script to detect when a players right arm (R6) touches another player. Here is a portion of the script,

game.Players.LocalPlayer.Character:WaitForChild("Right Arm").Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and not db and not damaged and 			hit.Parent.Humanoid ~= game.Players.LocalPlayer.Humanoid then
		if game.Players.LocalPlayer.Character.Humanoid.Health > 0 then
			damaged = true
			game.ReplicatedStorage.Punch:FireServer(hit.Parent.Humanoid)
		end
	end
end)

This is all written in a local script!

during the line that says "If hit.Parent:FindFirstChild("Humanoid)" there is an error that says "Humanoid is not a valid member of Player "players.Player1"" Why is the script getting the player from game.Players and not the players model? I used a print to check what the hand was hitting and it returned things like "Head" and "torso" nothing strange, what can I do to fix it? Thanks!

Edit: The script format looks really strange because the line ran out of room, In studio it looks fine.

3 comments

0

~= game.Players.LocalPlayer.Humanoid on line 2 you forgot to add 'Character' there, should be ~= game.Players.LocalPlayer.Character.Humanoid

0

What he said is correct, humanoid is a member of character not player. Character is a member of player though

0

Oh thanks! I didn't even realise I did that. I must have forgotten to type .character. thanks!