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

How to make a Brick that when you step in. Your Body will be Invisible?

Asked by 10 years ago

I wanna know the script that can make your Body Invisible like, When you step on a Brick. Your body will Invisible. But how?

3 answers

Log in to vote
0
Answered by 10 years ago
local part = Workspace.Part
part.Touched:connect(function(hitPart)
    local player = Game.Players:GetPlayerFromCharacter(hitPart.Parent)
    if player then
        for index, object in pairs(player.Character:GetChildren()) do 
            if object:IsA("BasePart") then 
                object.Transparency = 1 
                if object:FindFirstChild("face") then 
                    object.face.Transparency = 1 
                end 
            elseif object:IsA("Hat") and object:FindFirstChild("Handle") then 
                object.Handle.Transparency = 1 
            end
        end
    end
end)

part.TouchEnded:connect(function(hitPart)
    local player = Game.Players:GetPlayerFromCharacter(hitPart.Parent)
    if player then
        for index, object in pairs(player.Character:GetChildren()) do 
            if object:IsA("BasePart") and object.Name ~= "HumanoidRootPart" then 
                object.Transparency = 0
                if object:FindFirstChild("face") then 
                    object.face.Transparency = 0
                end 
            elseif object:IsA("Hat") and object:FindFirstChild("Handle") then 
                object.Handle.Transparency = 0
            end
        end
    end
end)
Ad
Log in to vote
-1
Answered by
mnaj22 44
10 years ago
-- Make this a local script in the brick.
Part = game.Workspace.Part -- Rename the second part to the brick
Player = game.Players.LocalPlayer
Character = Player.Character

function onTouched ()
    Character.("Right Arm").Transparency = 0
    Character.("Left Arm").Transparency = 0
    Character.("Right Leg").Transparency = 0
    Character.("Left Leg").Transparency = 0
    Character.Torso.Transparency = 0
    Character.Head.Transparency = 0
end

script.Parent.Touched:connect(onTouched)
0
How this helps/works. mnaj22 44 — 10y
Log in to vote
-1
Answered by
SanityMan 239 Moderation Voter
10 years ago

So you have your brick right? It is named something like "Part". You can use a Touch function in a script to make you invisible when you touch it with something like this:

function onTouched(part)
    if part.Parent.Humanoid ~= nil then --if the part's parent contains a humanoid (probably a player) then
        p = part.Parent:GetChildren() -- Gets children of part's parent into a table
        for i = 1,#p do --loops for the as many times as the # of p
            if p[i]:IsA("Part") then --if child of the character is a part then
                p[i].Transparency == 1 --set the transparency to 1 (invisible)
            end
        end
    end
end -- closes the function

script.Parent.Touched:connect(onTouched) --This connects the function to the touched event. It will work in this format only if the part is the script's parent

This script would belong as a child of the brick you want to be the touch button.

This script creates a function that is triggered by the touching event. If the part that touches it has a parent that has a humanoid child (it is probably a player), it will run through the player's objects and if they are parts it will turn them invisible. This script could be reversed by changing the 1 in the Transparency line to 0.

Hope it helped!

Answer this question