I have a vest that the player puts on whenever it is clicked. There is also a part on the vest that, when clicked, makes a mesh visible. The only problem is, the click detector doesn’t work once the vest is placed onto the character.
Here is the script that controls the meshes with the click detector:
local ClickDetector = script.Parent
db = false
local function InvAll(obj)
local shishMeshes = {
obj.Shish1,
obj.Shish2,
obj.Shish3
}
for _, shishMesh in ipairs(shishMeshes) do
if shishMesh then
shishMesh.Transparency = 1
wait(0)
end
end
end
local Num = 1
ClickDetector.MouseClick:Connect(function(player)
if not db then
db = true
if player.Character and player.Character:FindFirstChild("Humanoid") and player.Character:FindFirstChild("Vest") == nil then
if Num == 1 then
script.Parent.Parent.Parent.Shish1.Transparency = 0
Num = 2
elseif Num == 2 then
script.Parent.Parent.Parent.Shish2.Transparency = 0
script.Parent.Parent.Parent.Shish1.Transparency = 1
Num = 3
elseif Num == 3 then
script.Parent.Parent.Parent.Shish3.Transparency = 0
script.Parent.Parent.Parent.Shish2.Transparency = 1
Num = 4
elseif Num == 4 then
InvAll(ClickDetector.Parent.Parent)
Num = 1
end
end
wait(0.1)
db = false
end
end)
Here is a video of what is happening when the vest is on the player: