Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
talist 13
7 years ago
Edited 7 years ago

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

1
Also, use :Destroy() because :Remove() is deprecated. Mayk728 855 — 7y
2
Format your code correctly. Goulstem 8144 — 7y
0
yeah sorry here it is talist 13 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

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
0
ok now it's saying Humanoid is not a valid member of Model talist 13 — 7y
0
Do the zombie models have a Humanoid in them? Troidit 253 — 7y
0
Yes User#15029 30 — 7y
0
Going to accept? :3 User#15029 30 — 7y
0
yea dw I did talist 13 — 3y
Ad

Answer this question