Dear Devforum members, I been trying to make this code work for the entire day, yet I seriously still cant. I really need all the help I can get and I will begin explaining my big wild day of coding today.
So, the issue in this code I made is that whenever a new player joins that is blocked. The code doesnt make them invisible for some reason. However it works perfectly when I block them or unblock them in the game.
Please help me out here.
and this is the current code so far
BlockedUserIds = game:GetService("StarterGui"):GetCore("GetBlockedUserIds")
playerBlockedEvent = game:GetService("StarterGui"):GetCore("PlayerBlockedEvent")
playerUnBlockedEvent=game:GetService("StarterGui"):GetCore("PlayerUnblockedEvent")
game.Players.LocalPlayer.CharacterAdded:Connect(function(character)
for i,v in pairs(game.Players:GetChildren()) do
if table.find(BlockedUserIds,v.UserId) then
Invisibilazor(v)
end
end
end)
game.Players.PlayerAdded:Connect(function(player)
for i,v in pairs(game.Players:GetChildren()) do
if table.find(BlockedUserIds,v.UserId) then
Invisibilazor(v)
end
end
end)
if playerBlockedEvent then
playerBlockedEvent.Event:Connect(function(player)
Invisibilazor(player)
end)
end
if playerUnBlockedEvent then
playerUnBlockedEvent.Event:Connect(function(player)
visibilazor(player)
end)
end
function Invisibilazor(player)
if player.Character then
for i, part in ipairs(player.Character:GetDescendants()) do
if (part:IsA("BasePart") or part:IsA("Decal")) and part.Name ~= "HumanoidRootPart" then
part.Transparency = 1
end
end
else
player.CharacterAdded:Wait()
for i, part in ipairs(player.Character:GetDescendants()) do
if (part:IsA("BasePart") or part:IsA("Decal")) and part.Name ~= "HumanoidRootPart" then
part.Transparency = 1
end
end
end
end
function visibilazor(player)
if player.Character then
for i, part in ipairs(player.Character:GetDescendants()) do
if (part:IsA("BasePart") or part:IsA("Decal")) and part.Name ~= "HumanoidRootPart" then
part.Transparency = 0
end
end
else
player.CharacterAdded:Wait()
for i, part in ipairs(player.Character:GetDescendants()) do
if (part:IsA("BasePart") or part:IsA("Decal")) and part.Name ~= "HumanoidRootPart" then
part.Transparency = 0
end
end
end
end