The vehicle has been damaged by attaching an int value to the vehicle. It works fine in the event of a collision, but it doesn’t get damaged in the event of a gun attack. I want to reduce the int value when attacking with a gun.
script.Parent.Touched:Connect(function(otherPart)
local carHealth = script.Parent.Health
if otherPart.Parent = car then
carHealth.Value = carHealth.Value - (30)
end
end)
Perhaps make a script in the guns side.
'If the guns bullet hit something, search for the carHealth.
If carHealth exist, reduce the value to the desired amount.'
Use that script to get the name of what hits the gun then once you know it use:
local HealthValue = script.Parent:WaitForChild("Health")
script.Parent.Touched:Connect(function(hitPart)
if hitPart.Name == "NAMEHERE" then
HealthValue.Value -= 30
end
end)