演示视频 —
首先创建了两个part用于触发事件
然后是代码
local ServerStorage = game:GetService(‘ServerStorage’)
local Ys = workspace[‘隐身’]–记得切换此处变量
local Xs = workspace[‘现身’]–记得切换此处变量
Ys.Touched:Connect(function(x)
if x.Parent:FindFirstChild(“Humanoid”) then
local Child = x.Parent:GetDescendants( )
for k,v in pairs(Child) do
if v.ClassName==‘MeshPart’ then
v.Transparency = 1
elseif v.ClassName==“Accessory” then
if not v:FindFirstChild(“value”) then
local value = Instance.new(‘StringValue’)
value.Parent = v
value.Value=x.Parent.Name
v.Parent = ServerStorage
end
elseif v.ClassName==‘Decal’ then
if not v:FindFirstChild(“value”) then
local value = Instance.new(‘StringValue’)
value.Parent = v
value.Value=x.Parent.Name
v.Parent = ServerStorage
end
end
end
end
end)
Xs.Touched:Connect(function(x)
if x.Parent:FindFirstChild(“Humanoid”) then
for k,v in pairs(ServerStorage:GetChildren()) do
if v.Name==‘face’ and v.Value.Value==x.Parent.Name then
local Head = x.Parent:FindFirstChild(“Head”)
v.Parent = Head
elseif v.Value.Value==x.Parent.Name then
v.Parent = x.Parent
end
local Child = x.Parent:GetDescendants( )
for k,v in pairs(Child) do
if v.ClassName==‘MeshPart’ then
v.Transparency = 0
end
end
end
end
end)