Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What does : attempt to index nil with 'WalkSpeed' mean?

this is my script, its supposed to make the enemyhumanoid walkspeed and jumppower 0 but it isnt working

	Hitbox.Touched:Connect(function(Hit)
		if Hit:IsA("Part") or Hit:IsA("MeshPart") then
			if Hit.Parent ~= Character then
				local EHumanoid = Hit.Parent:FindFirstChild("Humanoid")
				local EHumRP = Hit.Parent:FindFirstChild("HumanoidRootPart")
				
				EHumanoid.WalkSpeed = 16
				EHumanoid.JumpPower = 50

thank you for your time

3 comments

1

or check (if EHumanoid then)

0

^

0

^

1 answer

You should see if the Humanoid exists before continuing your code. This can be done with a simple if statement.

Hitbox.Touched:Connect(function(Hit)
	if Hit:IsA("Part") or Hit:IsA("MeshPart") then
		if Hit.Parent ~= Character then
			local EHumanoid = Hit.Parent:FindFirstChild("Humanoid")
			local EHumRP = Hit.Parent:FindFirstChild("HumanoidRootPart")
			
			if EHumanoid then
				EHumanoid.WalkSpeed = 16
				EHumanoid.JumpPower = 50
			end
		end
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.