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 8 years ago

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

2 answers

Log in to vote
1
Answered by 8 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.

script.Parent.Touched:connect(function(hit)
    --we now know part "hit" has touched "TouchedPart"
    if hit.Parent:FindFirstChild("Humanoid", true) then
        for i, v in pairs(hit.Parent:GetChildren()) do
            if v:IsA("Basepart") then
                v.Transparency = 1
            end
        end
    end
end)
Ad
Log in to vote
0
Answered by 8 years ago


function onTouched(hit) -- function local torso = hit:FindFirstChild("Torso") local rightleg = hit:FindFirstChild("RightLeg") local rightArm = hit:FindFirstChild("RightArm") local leftLeg = hit:FindFirstChild("LeftLeg") local leftArm = hit:FindFirstChild("LeftArm") local headfoil = hit:FindFirstChild("Head") torso.Transparency = 1 rightArm.Transparency = 1 rightleg.Transparency = 1 leftArm.Transparency = 1 leftLeg.Transparency = 1 headfoil.Transparency = 1 end script.Parent.Touched:connect (onTouched) --listener

Answer this question