So I got a script that when a player joins the game it gets there friends and adds there username to a GUI button.
in studio it shows but when I play in Roblox the buttons doesn’t show all the time and if I reset the buttons go invisible.
If you want to see my script then tell me and Ill get it for you.
local description = Players:GetHumanoidDescriptionFromUserId(userid)
player.Character:FindFirstChild("Humanoid"):ApplyDescription(description)
end)
Players.PlayerAdded:Connect(function(player)
local friends = Players:GetFriendsAsync(player.UserId)
local function iterPageItems(pages)
return coroutine.wrap(function()
local pagenum = 1
while true do
for _, item in ipairs(pages:GetCurrentPage()) do
coroutine.yield(item, pagenum)
end
if pages.IsFinished then
break
end
pages:AdvanceToNextPageAsync()
pagenum = pagenum + 1
end
end)
end
local usernames = {}
local userids = {}
local isonline = {}
for item, pageNo in iterPageItems(friends) do
table.insert(usernames, item.Username)
table.insert(userids,item.Id)
table.insert(isonline,item.IsOnline)
end
for i=1,#usernames do
local clone = frame:Clone()
clone.Username.Text = usernames[i]
if isonline[i] then
clone.Status.BackgroundColor3 = Color3.fromRGB(0, 49, 0)
else
clone.Status.BackgroundColor3 = Color3.fromRGB(44,44,44)
end
local thumbnail, isready = Players:GetUserThumbnailAsync(userids[i],Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size48x48)
clone.Icon.Image = thumbnail
clone.Username:SetAttribute("UserId",userids[i])
clone.Parent = player.PlayerGui.FriendMorphGUI.FriendMorph
print(usernames[i].." is ready")
end
Could you send me a video of what you mean by the buttons don’t show up all the time? Also as for disappearing on respawn, try testing with ResetOnSpawn turned on and off for the ScreenGui and/or Frames and/or buttons
There might be two problems that I can think of so far:
The buttons disappear because ResetOnSpawn is either turned off or on for the buttons in ServerStorage.
ScreenGui may not be a child of Player.PlayerGui because it has not been added yet. In this case, you would need to add a wait() before you set the clone parent to the player. This would cause the buttons to not appear when you first join.
Btw, could you send any errors you receive in the output when this happens (if there is any)