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

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

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

✓ Accepted answer

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

2 comments

0

oh shoot, i'm really dumb

0

lol

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