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

How to make a part invisblelize a player??

Asked by 2 years ago

Is it possible to make a part invisblelize a player on touch then when not touch uninvisiblize the player.

0
yes, that would be possible BulletproofVast 1033 — 2y
1
How would I script it anyways?? blue_bunny0fficl 98 — 2y

2 answers

Log in to vote
1
Answered by 2 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.
01script.Parent.Touched:Connect(function(plr)
02    if plr.Parent:FindFirstChild("Humanoid") then
03        for i, v in pairs(plr.Parent:GetChildren()) do
04            if v:IsA("BasePart") then
05                v.Transparency = 1
06            end
07            if v:IsA("Accessory") then
08                v.Handle.Transparency = 1
09                for index, value in pairs(v.Handle:GetDescendants()) do
10                    if value:IsA("ParticleEmitter") then
11                        value.Transparency = NumberSequence.new(1)
12                    end
13                end
14            end
15        end
View all 37 lines...

Insert this into a part.

0
hi,how did you unserstod what he sayd?? Gigaset39 111 — 2y
0
hi,how did you unserstod what he sayd?? Gigaset39 111 — 2y
1
It worked thanks blue_bunny0fficl 98 — 2y
Ad
Log in to vote
3
Answered by 2 years ago
Edited 2 years ago

This code is the same as @bebokhouja2's answer but with explanations and few improvisations.

01script.Parent.Touched:Connect(function(hit) -- when the player touches the part
02    local character = (game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) ~= nil) and hit.Parent -- checks if hit is the player's limb
03    if character:FindFirstChildOfClass("Humanoid") then -- checks if the character has the "Humanoid" instance; detects if it's a real alive roblox character
04        for i, v in pairs(character:GetDescendant()) do -- gets all of its descendants (the children of children of children of ... children of a part)
05            if v:IsA("BasePart") then -- checks if it's a part/limb
06                v.Transparency = 1 -- sets the limb invisible
07            elseif v:IsA("Accessory") then -- if it's an accessory (e.g., Hat, Backpack, etc.)
08                v.Handle.Transparency = 1 -- sets the accessory invisible
09                for index, value in pairs(v.Handle:GetDescendants()) do -- gets its descendants
10                    if value:IsA("ParticleEmitter") then -- if it's a particle
11                        value.Transparency = NumberSequence.new(1) -- sets the particle to invisible
12                    end
13                end
14            end
15        end
View all 37 lines...
1
Thanks for the eplanation of the script blue_bunny0fficl 98 — 2y
1
I gave the other guy the awnser, because he did the script, but thanks for the explanation. blue_bunny0fficl 98 — 2y

Answer this question