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

How can i fix this?

Asked by 9 years ago

so im a novice scripter and this script wont work and i know why but dont know how to fix it:

script.Parent.ClickDetector.MouseClick:connect(function(hit)
        hit.torso.Transparency=0.5](http://)
        hit.Head.Transparency=0.5
        hit["Left Leg"].Transparency=0.5
        hit["Right Leg"].Transparency=0.5
        hit["Right Arm"].Transparency=0.5
        hit["Left Arm"].Transparency=0.5
end)

so i know that the player(hit) doesn't store the body parts but how would i find the body parts then. Sorry as this seems like a basic question but im just a little stuck. Any ideas?

2 answers

Log in to vote
0
Answered by
lukeb50 631 Moderation Voter
9 years ago
script.Parent.ClickDetector.MouseClick:connect(function(hit)
    cr=game.Workspace:FindFirstChild(hit.Name)
        cr.Torso.Transparency=0.5      
        cr.Head.Transparency=0.5
        cr["Left Leg"].Transparency=0.5
        cr["Right Leg"].Transparency=0.5
        cr["Right Arm"].Transparency=0.5
        cr["Left Arm"].Transparency=0.5
end)

what this will do:

the hit variable stores the player, the Character stores the body parts. so we look in the workspace for a object with the name of the player, thus getting the character

0
your a legend m8, ty electostriking 20 — 9y
0
np lukeb50 631 — 9y
0
You can also use hit.Character in this case. User#6546 35 — 9y
Ad
Log in to vote
0
Answered by
Vezious 310 Moderation Voter
9 years ago

I know this question is answered, but my way is more efficient.

script.Parent.ClickDetector.MouseClick:connect(function(Player)
local Character = game.Workspace:FindFirstChild(Player.Name)
 for i,v in pairs(Character:GetChildren()) do
if v:IsA("Part") then
v.Transparency = .5
end
end
end)

It's been tested.

Answer this question