Hey everyone, So I was doing some scripting stuff with this game I'm making, and I added these lines of code to remove an image from all the players in a server when a player leaves.
game:GetService("Players").PlayerRemoving:Connect(function(player)
local success, Async = pcall(function()
dsKey:UpdateAsync(playerKey..player.UserId, defaultSave)
end)
local mode
for i,v in pairs(game:GetService("ServerStorage").GameModes:GetDescendants()) do
if v.Name == player.Name then
waitTimes[v.Parent.Name]["PlayerCount"] = waitTimes[v.Parent.Name]["PlayerCount"] - 1
mode = v.Parent
v:Destroy()
end
end
for n,o in pairs(mode:GetChildren()) do
if game:GetService("Players"):FindFirstChild(o.Name) then
for a,b in pairs(game:GetService("Players")[o.Name].PlayerGui.GameMode.Main.Holder.Queue:GetChildren()) do
if b.Name == "Player_Icon" then
if b.Image == "https://www.roblox.com/headshot-thumbnail/image?userId="..player.UserId.."&width=420&height=420&format=png" then
b.Image = "nil"
b.Image = ""
game:GetService("Players")[o.Name].PlayerGui.GameMode.Main.Holder.TextLabel.Text = "Waiting for ["..(minPlayers-waitTimes[mode.Name]["PlayerCount"]).."] More Players..."
break
end
end
end
end
end
end)
The problem is, in the line " b.Image = "" ", it errors saying "Attempt to index boolean"
Before this error occurred, I didn't have the line " b.Image = "nil" ". The problem with this, though, was that it did remove the image link from the image label, but the image would not disappear for the player. And yes, b is an ImageLabel. I checked multiple times.
If anyone could help, that would be great.
Thanks! -Cruizer_Snowman
