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

Script ignores or does not recognize specific part, How to fix?

	elseif (hit.Parent.Parent.Hull.Name == "FrontArmor") then -- hitparts
		print("voce danificou o chassi")
		local HitSound = hit.Parent:findFirstChild("Pen"):Clone()
		HitSound.Parent = hit
		HitSound:Play()
		hit.Parent.Parent:findFirstChild("Damage").Value = hit.Parent.Parent:findFirstChild("Damage").Value - dealingdamage /2 -- makes the damage

Basically this script detects hit on some object and the damage, I set up this line to detect hit in a specific part or it should ... because in test mode this line is ignored, there is nothing in the output related to errors or something like that.

2 comments

0

the part i want to hit is Called "FrontArmor

0

you’re using deprecated methods. switch to FindFirstChild. i’ll rewrite the script. don’t use elseif like that. i’ll show that

1 answer

✓ Accepted answer

Script Inside the damaging part itself:

script.Parent.Touched:Connect(function(hit)
    local doesPlrHaveArmor = hit.Parent:FindFirstChild(“FrontArmor”)
    if hit.Parent:FindFirstChildOfClass(“Humanoid”) and not doesPlrHaveArmor then
        hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health -  your damage
    elseif doesPlrHaveArmor then
        hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - your damage / 2
    end
end)

4 comments

0

this script that I did was to simulate armor in a vehicle, that one that you wrote works for a humanoid, I'll try to modify this one you wrote

0

it says "touched is not a valid part of the model"

0

I Will send the whole script on the answers

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