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
11 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 — 11y

2 answers

Log in to vote
9
Answered by 11 years ago
01local part = Workspace.Part
02part.Touched:connect(function(hitPart)
03    local player = Game.Players:GetPlayerFromCharacter(hitPart.Parent)
04    if player then
05        for index, object in pairs(player.Character:GetChildren()) do
06            if object:IsA("BasePart") then
07                object.Transparency = 1
08                if object:FindFirstChild("face") then
09                    object.face.Transparency = 1
10                end
11            elseif object:IsA("Hat") and object:FindFirstChild("Handle") then
12                object.Handle.Transparency = 1
13            end
14        end
15    end
View all 32 lines...
Ad
Log in to vote
3
Answered by
HexC3D 830 Moderation Voter
11 years ago
01script.Parent.Touched:connect(function()
02for i, v in pairs (game.Players:GetPlayers()) do
03v.Character.Torso.Transparency = 1
04v.Character.Head.Transparency = 1
05v.Character["Left Leg"].Transparency = 1
06v.Character["Left Arm"].Transparency = 1
07v.Character["Right Arm"].Transparency = 1
08v.Character["Right Leg"].Transparency = 1
09end
10end)
11script.Parent.StoppedTouching:connect(function()
12for i, v in pairs ( game.Players:GetPlayers()) do
13v.Character.Torso.Transparency = 0
14v.Character.Head.Transparency = 0
15v.Character["Left Leg"].Transparency = 0
16v.Character["Left Arm"].Transparency = 0
17v.Character["Right Arm"].Transparency = 0
18v.Character["Right Leg"].Transparency = 0
19end
20end)

Put this script into the part you want

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

Answer this question