So I want to make a script where a player becomes completley invisible for all players but he is slightly visible for himself. Here is my server script:
game.ReplicatedStorage.BecomeInvisible.OnServerEvent:Connect(function(player, invisible)
for i,v in pairs(player.Character:GetChildren()) do
if invisible == true then
for i,j in pairs(v:GetChildren()) do
if j:IsA("Part") or j:IsA("MeshPart") or j:IsA("Decal") then
if not (j.Name == "HumanoidRootPart") then
spawn(function()
for i=0,1,0.1 do
j.Transparency = i
wait(0.01)
end
end)
end
end
end
if v:IsA("Part") or v:IsA("MeshPart") or v:IsA("Decal") then
if not (v.Name == "HumanoidRootPart") then
spawn(function()
for i=0,1,0.1 do
v.Transparency = i
wait(0.01)
end
end)
end
end
else
for i,j in pairs(v:GetChildren()) do
if j:IsA("Part") or j:IsA("MeshPart") or j:IsA("Decal") then
if not (j.Name == "HumanoidRootPart") then
spawn(function()
for i=1,0,-0.1 do
j.Transparency = i
wait(0.01)
end
end)
end
end
end
if v:IsA("Part") or v:IsA("MeshPart") or v:IsA("Decal") then
if not (v.Name == "HumanoidRootPart") then
spawn(function()
for i=1,0,-0.1 do
v.Transparency = i
wait(0.01)
end
end)
end
end
end
end
end)
and here is my client side script
local debounce = false
local player = game.Players.LocalPlayer
local character = player.Character
script.Parent.MouseButton1Click:Connect(function()
if debounce == false then
debounce = true
if script.Parent.Text == "Become Invisible" then
game.ReplicatedStorage.BecomeInvisible:FireServer(true)
script.Parent.Text = "Become Visible"
for i,v in pairs(player.Character:GetChildren()) do
for i,j in pairs(v:GetChildren()) do
if j:IsA("Part") or j:IsA("MeshPart") or j:IsA("Decal") then
if not (j.Name == "HumanoidRootPart") then
spawn(function()
for i=0,.5,0.1 do
j.Transparency = i
wait(0.005)
end
end)
end
end
end
if v:IsA("Part") or v:IsA("MeshPart") or v:IsA("Decal") then
if not (v.Name == "HumanoidRootPart") then
spawn(function()
for i=0,.5,0.1 do
v.Transparency = i
wait(0.005)
end
end)
end
end
end
else
game.ReplicatedStorage.BecomeInvisible:FireServer(false)
script.Parent.Text = "Become Invisible"
for i,v in pairs(player.Character:GetChildren()) do
for i,j in pairs(v:GetChildren()) do
if j:IsA("Part") or j:IsA("MeshPart") or j:IsA("Decal") then
if not (j.Name == "HumanoidRootPart") then
spawn(function()
for i=1,.5,-0.1 do
j.Transparency = i
wait(0.005)
end
end)
end
end
end
if v:IsA("Part") or v:IsA("MeshPart") or v:IsA("Decal") then
if not (v.Name == "HumanoidRootPart") then
spawn(function()
for i=1,.5,-0.1 do
v.Transparency = i
wait(0.005)
end
end)
end
end
end
end
wait(1)
debounce = false
end
end)
for i,v in pairs(player.Character:GetChildren()) do
for i,j in pairs(v:GetChildren()) do
if j:IsA("Part") or j:IsA("MeshPart") or j:IsA("Decal") then
if not (j.Name == "HumanoidRootPart") then
spawn(function()
for i=0,1,0.1 do
j.Transparency = i
wait(0.01)
end
end)
end
end
end
if v:IsA("Part") or v:IsA("MeshPart") or v:IsA("Decal") then
if not (v.Name == "HumanoidRootPart") then
spawn(function()
for i=0,1,0.1 do
v.Transparency = i
wait(0.01)
end
end)
end
end
for i,j in pairs(v:GetChildren()) do
if j:IsA("Part") or j:IsA("MeshPart") or j:IsA("Decal") then
if not (j.Name == "HumanoidRootPart") then
spawn(function()
for i=1,0,-0.1 do
j.Transparency = i
wait(0.01)
end
end)
end
end
end
if v:IsA("Part") or v:IsA("MeshPart") or v:IsA("Decal") then
if not (v.Name == "HumanoidRootPart") then
spawn(function()
for i=1,0,-0.1 do
v.Transparency = i
wait(0.01)
end
end)
end
end
end
but whenever I press the button it makes me completley invisible. Any ideas?