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

Ontouch Transparency

Asked by
JJ_B 250 Moderation Voter
10 years ago

What script would I use to make my character go invisible when touching a brick and visible when not touching it? I've tried a lot.

0
Why have I got -1 likes? What's wrong with this question? JJ_B 250 — 10y

2 answers

Log in to vote
9
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
3
Answered by
HexC3D 830 Moderation Voter
10 years ago

script.Parent.Touched:connect(function() for i, v in pairs (game.Players:GetPlayers()) do v.Character.Torso.Transparency = 1 v.Character.Head.Transparency = 1 v.Character["Left Leg"].Transparency = 1 v.Character["Left Arm"].Transparency = 1 v.Character["Right Arm"].Transparency = 1 v.Character["Right Leg"].Transparency = 1 end end) script.Parent.StoppedTouching:connect(function() for i, v in pairs ( game.Players:GetPlayers()) do v.Character.Torso.Transparency = 0 v.Character.Head.Transparency = 0 v.Character["Left Leg"].Transparency = 0 v.Character["Left Arm"].Transparency = 0 v.Character["Right Arm"].Transparency = 0 v.Character["Right Leg"].Transparency = 0 end end)

Put this script into the part you want

0
Oops I forgot when not touching it let me add it mmk. HexC3D 830 — 10y
0
Cheers JJ_B 250 — 10y
0
Fixed it. HexC3D 830 — 10y
0
StoppedTouching is deprecated. Articulating 1335 — 10y
View all comments (4 more)
1
In what way it works?I am using functions that not that many use. HexC3D 830 — 10y
0
I just switched it for TouchEnded JJ_B 250 — 10y
1
This also affects all players in the game, not just the Toucher. Articulating 1335 — 10y
0
Wow JJ_B 250 — 10y

Answer this question