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

Have Script run only if Parent's CanCollide is true?

Asked by
AAzterr 27
5 years ago

I need this script to run only if it's parent's CanCollide property is true. I already tried putting if script.Parent.CanCollide = true then but that broke the whole script. What thing do I add?

script.Parent.Touched:connect(function(hit)
    if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent.Humanoid.Health = 0
    end
end)

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

sir u were pretty close but if u want to check a variable ull have to put two "="s. or to rewrite urs:

if script.Parent.CanCollide == true then

instead of

if script.Parent.CanCollide = true then
0
oh shoot, i'm really dumb AAzterr 27 — 5y
0
lol TheluaBanana 946 — 5y
Ad

Answer this question