What I'm trying to accomplish is:
- Player equips the tool and activates it.
- It clones the accessories inside of the tool.
- If activated again, it removes the added accessories.
The first script does equip the accessories, but the second script won't turn them invisible/visible. [For clarification on the first script, it becomes disabled to prevent the player from continuously equipping the tool and getting more parts and welds spawned.]
Working script:
repeat wait() until script.Parent.Parent.Parent.ClassName == "Player"
local Player = script.Parent.Parent.Parent
local Character = Player.Character
local Tool = script.Parent
Tool.Equipped:Connect(function(mouse)
local Mask = script.Mask:Clone()
Mask.Position = Character.Head.Position
local MaskWeld = script.MaskWeld:Clone()
MaskWeld.Part0 = Character.Head
MaskWeld.Part1 = Mask
MaskWeld.Parent = Mask
Mask.Parent = Character
local Hood = script.Hood:Clone()
Hood.Position = Character.Head.Position
local HoodWeld = script.HoodWeld:Clone()
HoodWeld.Part0 = Character.Head
HoodWeld.Part1 = Hood
HoodWeld.Parent = Hood
Hood.Parent = Character
script.Disabled = true
end)
2nd (Broken) Script:
repeat wait() until script.Parent.Parent.Parent.ClassName == "Player"
local clicked = true
local Player = script.Parent.Parent.Parent
local Character = Player.Character
local Tool = script.Parent
local function onEquip()
Character.Mask.Transparency = 1
Character.Hood.Transparency = 0
end
local function onUnEquip()
Character.Mask.Transparency = 0
Character.Hood.Transparency = 1
end
Tool.Activated:Connect(function()
if clicked == false then
onEquip()
clicked = true
elseif clicked == true then
onUnEquip()
clicked = false
end
end)
Any and all help is appreciated with this weirdly complicated task. If you have any alternate solutions then feel free to post em.
In the workspace, the tool currently looks like:
Tool
Broken Script & Working Script
(Inside the working script) Two parts & Welds for the two parts
