I have a function trying to turn people invisible but it refuses to work or give me an error message, how would i fix it?
local limit = 5
local Site = script.Parent.Parent.Parent.Site
local TargetSite = script.Parent.Parent.Parent.Parent.Unit1.Site
function Demat(model)
print("demating")
for i, v in pairs(model:GetChildren()) do
if v:IsA("Part") then
v.Transparency = v.Transparency + 1
elseif v:IsA("Accessory") then
v.Handle.Transparency = v.Handle.Transparency + 1
elseif v:IsA("Accoutrement") then
v.Handle.Transparency = v.Handle.Transparency + 1
end
end
end
function onClicked()
if (script.Parent.Parent:FindFirstChild("Active")~= nil) then
local c = game.Players:GetChildren()
for i = 1, #c do
if (c[i].Character ~= nil) and ((c[i].Character.Torso.Position - script.Parent.Position).magnitude < limit) then
Site.UpperFX.Enabled = true
Site.LowerFX.Enabled = true
Site.PointLight.Enabled = true
Site.BeamSound:Play()
c[i].Character.Torso.Anchored = true
Demat()
wait(4)
c[i].Character.Torso.Anchored = false
wait(0.01)
c[i].Character.Torso.CFrame = CFrame.new(script.Parent.Parent.Parent.Parent.Unit1.Site.Position + Vector3.new (math.random(-10,10)))
wait(0.01)
c[i].Character.Torso.Anchored = true
Site.UpperFX.Enabled = false
Site.LowerFX.Enabled = false
Site.PointLight.Enabled = false
TargetSite.UpperFX.Enabled = true
TargetSite.LowerFX.Enabled = true
TargetSite.PointLight.Enabled = true
TargetSite.BeamSound:Play()
wait(4)
TargetSite.UpperFX.Enabled = false
TargetSite.LowerFX.Enabled = false
TargetSite.PointLight.Enabled = false
c[i].Character.Torso.Anchored = false
end
end
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
