The code runs and it doesn’t give any errors, but the transparency of the parts isn’t set.
How can I fix this?
elseif ChosenEvent == "Event9" then
local Players = game.Players:GetPlayers()
local CountValue = Instance.new("IntValue",game.Workspace)
local Number = 0
for i, Count in pairs(Players) do
local Number = Number + 1
CountValue.Value = Number
end
if CountValue.Value >= 1 then
print("2playersingame")
local RandomPlayer1 = Players[math.random(#Players)]
local RandomPlayer2 = Players[math.random(#Players)]
local P1Char = RandomPlayer1.Character
local P2Char = RandomPlayer2.Character
if P1Char and P2Char then
for i, Part in pairs(P1Char:GetChildren() and P2Char:GetChildren()) do
if Part:IsA("Part") or Part:IsA("MeshPart") then
Part.Transparency = 1
if Part:IsA("Accessory") then
Part:Destroy()
end
end
wait(3)
for i, Part in pairs(P1Char:GetChildren() and P2Char:GetChildren()) do
if Part:IsA("Part") then
Part.Transparency = 0
end
end
end
end
else
print("Only 1 player in game")
local RandomPlayer1 = Players[math.random(#Players)]
local Char = RandomPlayer1.Character
if Char then
for i, Part in pairs(Char:GetChildren()) do
if Part:IsA("Part") or Part:IsA("MeshPart") then
Part.Transparency = 1
if Part:IsA("Accessory") then
Part:Destroy()
end
end
end
wait(3)
for i, Part in pairs(Char:GetChildren()) do
if Part:IsA("Part") or Part:IsA("MeshPart") then
Part.Transparency = 0
end
end
CountValue:Destroy()