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?
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
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.