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

How do you make a humanoid that is removed when touching a certain gear?

Asked by 9 years ago

I need to know how to make a NPC that is removed when touching a certain gear in game and then re-appear after a minute

1 answer

Log in to vote
0
Answered by
Hexcede 52
9 years ago

LargeVIII, Heres your code:

local human = script.Parent.Parent
script.Parent.Touched:connect(function(hit)
    if hit.Parent.Name == "Gear Name" then -- Change Gear Name to whatever the name of the gear should be.
        children = human:GetChildren() -- A table of the children in the human
        for i,child in pairs(children) do -- Simple loop
            if child:IsA("BasePart") then -- Don't change BasePart to anything
                child.Transparency = 1 -- Makes it invisible
                child.Anchored = true -- Makes sure that it doesn't fall out of the world
                child.CanCollide = false -- Makes it so that it can go through stuff
            end
        end
        wait(time) -- change time to the time it is gone
        for i,child in pairs(children) do -- Simple loop
            if child:IsA("BasePart") then -- Don't change BasePart to anything
                child.Transparency = 0 -- Makes it visible
                child.Anchored = true -- Makes it unfrozen
                child.CanCollide =true -- Makes it so that it can't go through stuff
            end
        end
end)

Make sure you put that in the part of the human you want to be the activator e.g, the torso of the humanoid. Sincerely, crazycittykat

Ad

Answer this question