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

How do i fix this? Health is not a valid member of Model... PLEASE HELP

Ok so here is the local script

 Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
Ammo = 1

Mouse.KeyDown:connect(function(key)
	key = key:lower()
	if key == "f" and Ammo >0 then
		local x = Instance.new("Part", workspace)
		x.Size = Vector3.new(20,0,0)
		x.Shape = "Ball"
		x.BrickColor = BrickColor.new ("Toothpaste")
		x.Material = "Neon"
		x.Transparency = 0.2
		x.TopSurface = "Smooth"
		x.BottomSurface = "Smooth"
		x.CanCollide = false
		x.CFrame = Player.Character.Torso.CFrame * CFrame.new(0,-1,-5)
		local v = Instance.new("BodyVelocity", x)
		v.velocity = Player.Character.Torso.CFrame.lookVector * 90
		
		v.maxForce = Vector3.new(math.huge, math.huge, math.huge)
		Ammo = Ammo -1
		wait(1)
		Ammo = 1

		
	
		
		
	
		
		local S = script["Script"]:clone()
		S.Parent = x
		x.Parent = workspace
		wait(2)
		
		x:remove()
		
		
	end
	
end)

But i made it so it can attack but gets that error heres the script that won't work.


script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Zombie")~=nil then
hit.Parent.Zombie.Health = hit.Parent.Zombie.Health - 4
	     script.Parent.remove()
	
	end
	
end)

could someone tell me whats wrong and put the script down there thanks :D

3 comments

1

Also, use :Destroy() because :Remove() is deprecated.

2

Format your code correctly.

0

yeah sorry here it is

1 answer

✓ Accepted answer

Explanation

It means exactly what it says. Health is not a valid member of Zombie. In other words, a model has no property Health.

I know what you're trying to do though (yeah spooky i know)

Health is a property of Humanoid, not the model 'Zombie'

Solution

So you'd want to do:

hit.Parent.Zombie.Humanoid.Health = hit.Parent.Zombie.Humanoid.Health - 4

instead of

hit.Parent.Zombie.Health = hit.Parent.Zombie.Health - 4

5 comments

0

ok now it's saying Humanoid is not a valid member of Model

0

Do the zombie models have a Humanoid in them?

0

Yes

0

Going to accept? :3

0

yea dw I did

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