make other players invisible with a switch. this script does not work. why?
local button = script.Parent
local on = false
button.MouseButton1Click:Connect(function()
if on == true then
on = false
button:TweenPosition(UDim2.new(0.249, 0,0.5, 0),"Out","Quad",0.2,true)
elseif on == false then
on = true
button:TweenPosition(UDim2.new(0.800, 0,0.5, 0),"Out","Quad",0.2,true)
end
end)
if on == true then
--invis
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
for _, Player in pairs(game.Players:GetPlayers()) do
local Character = Player.Character
if (Player.Character ~= Character) then
local CharacterStuff = Character:GetDescendants()
for _, BodyPart in pairs(CharacterStuff) do
if (BodyPart:IsA("BasePart")) then
BodyPart.Transparency = 1
end
end
end
end
end)
end)
end
