Ad
Log in to vote
0

Making a car damaging system with FE Gun Kit But i have trouble damaging the car???

Asked by 7 days ago

So I'm making a car damaging system. I have the function for turning the car into a pile of scrap once it reaches 0 health, but I have trouble for making the car take damage once a player shoots at it with a gun from FE Gun Kit. Here is my code so far:

while true do
    wait(0.5)
    for i, v in pairs(Car:GetDescendants()) do
        if v:FindFirstChildOfClass("Attachment") and v.Name == "Attachment" then
            Health.Value -= 50
            if Health.Value == 0 then
                for i, v in pairs(Car:GetDescendants()) do
                    if v:IsA("Part") or v:IsA("MeshPart") then
                        v.Material = Enum.Material.CorrodedMetal
                        Script1:Destroy()
                        Script2:Destroy()
                        if Seat.Occupant then
                            Seat.Occupant.Parent.Humanoid.Health = 0
                        end
                    end
                end
            end
        end
    end
end

The bullet part that the gun shoots is actually an Attachment that sticks to where you shot. So I tried making it so when it detects an attachment it lowers the health. However, that does not work. I dont get any errors but it does not lower the health! Please help

Answer this question