In the beginning of this function i am trying to make a gui visible for everyone. It does nut work and ‘a’ is printed but not ‘b’.
local spins = 50
local function playerPick()
print("a")
for i,v in pairs(plrs:GetPlayers()) do
print("b")
v.PlayerGui:WaitForChild("PlayerPick").Frame.Visible = true
end
for number,plr in pairs(plrs:GetPlayers()) do
if plr.IsAlive.Value == true and spins ~= 0 then
wait(0.05)
local avatarImage = plrs:GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
plr.PlayerGui.PlayerPick.Frame.ImageLabel.Image = avatarImage
plr.PlayerGui.PlayerPick.Frame:FindFirstChild("Name").Text = plr.Name
spins -= 1
game.SoundService.SFX.ButtonClick:Play()
if number == #plrs:GetPlayers() and spins ~= 0 then
playerPick()
else if number == #plrs:GetPlayers() and spins == 0 then
game.SoundService.SFX.GuesserChosen:Play()
end
end
end
end
end
playerPick()
“plrs” is not a variable. Add local plrs = game:GetService("Players") at the top at and it should work. And also, I do not recommend you getting the players this way. You could do something like:
local player
game:GetService("Players").PlayerAdded:Connect(function(plr)
player = plr
end)
local function playerPick(plr)
player.PlayerGui:WaitForChild("PlayerPick").Frame.Visible = true
end
playerPick(player)
The script is pretty big so i only added the part i needed help with here, plrs is actually a variable.Do you have any other idea of what might be the problem?
ok instead of printing ‘a’ can you try printing plrs:GetPlayers(), because i think the issue is that the players havent yet loaded, so getPlayers returns empty, causing the loop to not run, im not sure tho try printing it and see what happens