Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can i fix this?

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

✓ Accepted answer
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

3 comments

0

your a legend m8, ty

0

np

0

You can also use hit.Character in this case.

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.