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

How to change player parts ontouch?

Asked by 9 years ago

I have not seemed to figure this out yet...

2 answers

Log in to vote
1
Answered by 9 years ago

This script loops through all the parts in the player when the player touches the scripts parent and sets the transparency of all the parts in player to 1.

01script.Parent.Touched:connect(function(hit)
02    --we now know part "hit" has touched "TouchedPart"
03    if hit.Parent:FindFirstChild("Humanoid", true) then
04        for i, v in pairs(hit.Parent:GetChildren()) do
05            if v:IsA("Basepart") then
06                v.Transparency = 1
07            end
08        end
09    end
10end)
Ad
Log in to vote
0
Answered by 9 years ago
01function onTouched(hit) -- function
02local torso = hit:FindFirstChild("Torso")
03local rightleg = hit:FindFirstChild("RightLeg")
04local rightArm = hit:FindFirstChild("RightArm")
05local leftLeg = hit:FindFirstChild("LeftLeg")
06local leftArm = hit:FindFirstChild("LeftArm")
07local headfoil = hit:FindFirstChild("Head")
08torso.Transparency = 1
09rightArm.Transparency = 1
10rightleg.Transparency = 1
11leftArm.Transparency = 1
12leftLeg.Transparency = 1
13headfoil.Transparency = 1
14end
15 
16script.Parent.Touched:connect (onTouched) --listener

Answer this question