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

Why when I step on a morph my body goes invisible, but when I step on it again, it doesn't?

Asked by
LawlR 182
6 years ago
Edited 6 years ago

When I step on a morph I made, everything works and I get changed into the morph. Then when I step on a button it changed me back to normal, and makes my body parts visible again. However after that if I step on the morph again, my body parts don't go invisible. Why is this and how do I fix this?

Here is the part that turns you back to normal

function BTN(hit)
    if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Chest") ~= nil then
        local char = hit.Parent
        for i,v in pairs(char:GetChildren()) do
            if v.Name == "Chest" then
                char.Chest:Destroy()
            elseif v.Name == "Head" or v.Name == "Left Leg" or v.Name == "Left Arm" or v.Name == "Right Leg" or v.Name == "Right Arm" or v.Name == "Torso" then
                v.Transparency = 0
            end
        end
    end
    if game.Lighting:FindFirstChild(hit.Parent.Name) ~= nil then
        for i,v in pairs(game.Lighting:FindFirstChild(hit.Parent.Name):GetChildren()) do
            v.Parent = hit.Parent
        end
    end
    game.Lighting:FindFirstChild(hit.Parent.Name.." Bool").Value = false
end
------------------------------------------------
wait()
part4.Touched:Connect(BTN) -- Back to normal

And here is the morph invisibility part

function Invisibility3(hit)
    if hit.Parent:findFirstChild("Humanoid") then
        local char = hit.Parent
        if game.Lighting:findFirstChild(hit.Parent.Name.." Bool") == nil then
            local Bool = Instance.new("BoolValue",game.Lighting)
            Bool.Name = (char.Name.." Bool")

        end
        for i,v in pairs(char:GetChildren()) do
            if game.Lighting:FindFirstChild(hit.Parent.Name.." Bool").Value == false then
                game.Lighting:FindFirstChild(hit.Parent.Name.." Bool").Value = true
            end
            if v.Name == "Head" or v.Name == "Left Leg" or v.Name == "Left Arm" or v.Name == "Right Leg" or v.Name == "Right Arm" or v.Name == "Torso" and game.Lighting:FindFirstChild(hit.Parent.Name.." Bool").Value == true then
                v.Transparency = 1
            end
            if v.Name == "Head" then
                v.face:Destroy()
            end
        end
    end
end
------------------------------------------------
wait()
part3.Touched:Connect(Invisibility3) -- Invisibility
0
Nobody here is a mind reader. Avigant 2374 — 6y
0
Added some script LawlR 182 — 6y

Answer this question