Answered by
7 years ago Edited 7 years ago
You have to link the functions to the Equipped and Activate events (and also move your ends around):
01 | local tool = script.Parent |
03 | local function onActivate() |
04 | local char = tool.Parent.Parent |
05 | char.Head.Transparency = 1 |
06 | char [ 'Right Arm' ] .Transparency = 1 |
07 | char [ 'Left Arm' ] .Transparency = 1 |
08 | char.Torso.Transparency = 1 |
09 | char [ 'Right Leg' ] .Transparency = 1 |
10 | char [ 'Left Leg' ] .Transparency = 1 |
12 | tool.Activated:Connect(onActivate) |
14 | local function onUnequip() |
15 | local char = tool.Parent.Parent |
16 | char.Head.Transparency = 0 |
17 | char [ 'Right Arm' ] .Transparency = 0 |
18 | char [ 'Left Arm' ] .Transparency = 0 |
19 | char.Torso.Transparency = 0 |
20 | char [ 'Right Leg' ] .Transparency = 0 |
21 | char [ 'Left Leg' ] .Transparency = 0 |
23 | tool.Unequipped:Connect(onUnequip) |
But a better way to do it might be to iterate through the children of the character and set the transparency of all the parts to 0/1:
01 | function setTransparency(trans) |
02 | local char = script.Parent.Parent |
03 | for _,v in pairs (char:GetDescendants()) do |
04 | if v:IsA( "BasePart" ) and v.Name ~ = "HumanoidRootPart" then |
05 | v.Transparency = trans |
09 | script.Parent.Equipped:Connect( function () |
12 | script.Parent.Unequipped:Connect( function () |