How do I make this script only effect enemys and not actual players

This is a touch function I have here, but the problem is that I want it to only effect the enemy humanoid and not the players humanoid. I tried a lot of things but I couldn’t seem to figure it out, thank you.

Code:

script.Parent.Touched:Connect(function(SpeedHit)
local Human = SpeedHit.Parent.Humanoid
if Human then
Human.WalkSpeed = 0
end
end)

All you have to do is check if the Players service can’t find a player associated with the character.

script.Parent.Touched:Connect(function(SpeedHit)
	local Human = SpeedHit.Parent.Humanoid
	if Human then
		local Player = game:GetService("Players"):GetPlayerFromCharacter(Human.Parent)
		if not Player then
			Human.WalkSpeed = 0
		end
	end
end)

@untamedpumkin Also, you should properly format your code. A proper format should look like this:

image

You do not have to include the lua part, but I just personally use it.

This is the solution, how ever you (@untamedpumkin) should format your code like this

` ``lua

` ``

Just don’t add the spaces in ` ``.
Put your code in the middle of the thing like a table.