What do you want to achieve? Keep it simple and clear!
Basically I want to be able to show a gui to all clients.
What is the issue? Include screenshots / videos if possible!
I somewhat know how to, though the gui is only visible to the local player.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve looked through the Dev hub and my best guess is to loop through all clients playerGui and show it.
In a server script, I fire a remote event to all clients. Then on a local script I recieve the event and show the relative stuff. The problem is that the local player only sees the stuff, in this case a headshot of their player profile. How would I make this available for everyone to see. Perhaps I show the gui on the server?
Server script
game.ReplicatedStorage.PlayerProfile:FireAllClients()
Local script
local templatetextlabel = script.Parent.Parent.WinnerGui.Template:WaitForChild("TextLabel")
local Players = game:GetService("Players")
local player = Players
local frame = script.Parent.Parent.WinnerGui:WaitForChild("Template")
game.ReplicatedStorage.PlayerProfile.OnClientEvent:Connect(function()
local userId = player.UserId
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
frame.Visible = true
local imageLabel = script.Parent.Parent.WinnerGui.Template.Frame:GetChildren()
imageLabel = imageLabel[math.random(1, #imageLabel)]
imageLabel.Visible = true
imageLabel.Image = content
templatetextlabel:Clone()
templatetextlabel.Visible = true
templatetextlabel.Position = imageLabel.Position - UDim2.new(0.002,0,0,0)
while wait() do
templatetextlabel.Text = "Kills:" .. player.leaderstats.Kills.Value
end
print("fired")
end)
Is there any way to show the UI to all clients, how would it even know to get the player’s userID then?
hypotesis
(hypotesis)
August 28, 2020, 11:58am
#2
what exactly would you like to show?
I want to show each Player’s profile picture, and their kills amount.
hypotesis
(hypotesis)
August 28, 2020, 12:16pm
#5
try this:
local templatetextlabel = script.Parent.Parent.WinnerGui.Template:WaitForChild("TextLabel")
local frame = script.Parent.Parent.WinnerGui:WaitForChild("Template")
game.ReplicatedStorage.PlayerProfile.OnClientEvent:Connect(function()
for i,player in pairs(game.Players:GetPlayers()) do
local userId = player.UserId
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
local content, isReady = game.Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
frame.Visible = true
local imageLabel = script.Parent.Parent.WinnerGui.Template.Frame:GetChildren()
imageLabel = imageLabel[i]
imageLabel.Visible = true
imageLabel.Image = content
templatetextlabel:Clone()
templatetextlabel.Visible = true
templatetextlabel.Position = imageLabel.Position - UDim2.new(0.002,0,0,0)
templatetextlabel.Text = "Kills:" .. player.leaderstats.Kills.Value
end
end)
you did get the gui to all clients part… just you didn’t loop through the players
For some reason it says “UserId” is not a valid member of player?
That is my output.
Player’s is undefined. So I switched to players.
hypotesis
(hypotesis)
August 28, 2020, 12:35pm
#9
wait… Player is defined in the loop players isn’t do
local content, isReady = game.Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
and replace that line
1 Like
Oh wait that’s not the issue, lol. I changed to player and it says UserId is not a valid member of “Players”. But on this line…
local userId = player.UserId
?
hypotesis
(hypotesis)
August 28, 2020, 12:47pm
#11
just copy this:
hypotesis:
try this:
local templatetextlabel = script.Parent.Parent.WinnerGui.Template:WaitForChild("TextLabel")
local frame = script.Parent.Parent.WinnerGui:WaitForChild("Template")
game.ReplicatedStorage.PlayerProfile.OnClientEvent:Connect(function()
for i,player in pairs(game.Players:GetPlayers()) do
local userId = player.UserId
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
local content, isReady = game.Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
frame.Visible = true
local imageLabel = script.Parent.Parent.WinnerGui.Template.Frame:GetChildren()
imageLabel = imageLabel[i]
imageLabel.Visible = true
imageLabel.Image = content
templatetextlabel:Clone()
templatetextlabel.Visible = true
templatetextlabel.Position = imageLabel.Position - UDim2.new(0.002,0,0,0)
templatetextlabel.Text = "Kills:" .. player.leaderstats.Kills.Value
end
end)
you did get the gui to all clients part… just you didn’t loop through the players
I edited it
srry for the confusion
Nope, I still get the same error. “UserId is not a valid member of Players”, perhaps it’s because getting UserId from the service “Players” and not a Player instance? Edit: Never mind I don’t think thats why.
hypotesis
(hypotesis)
August 28, 2020, 12:54pm
#13
you are not supposed to use Players. Use an actual player instance. just copy my code above
The same error keeps coming back and forth, dunno why.
Sniperkaos
(Swag Messiah)
August 28, 2020, 12:57pm
#15
wait so what exactly are you trying to do here?
I’m firing a remote event to all clients from the server. In a local script I pick up that event and show the above code. I’m trying to make each clients profile visible to everyone, however, I don’t know how.
FerbZides
(FerbZides)
August 28, 2020, 1:01pm
#17
does it still occur? if yes then can u show me your current code?
Yes it still errors, this is the current code…
local templatetextlabel = script.Parent.Parent.WinnerGui.Template:WaitForChild("TextLabel")
local frame = script.Parent.Parent.WinnerGui:WaitForChild("Template")
game.ReplicatedStorage.PlayerProfile.OnClientEvent:Connect(function()
frame.Visible = true
for i,player in pairs(game.Players:GetPlayers()) do
local userId = player.UserId
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
local content, isReady = player:GetUserThumbnailAsync(userId, thumbType, thumbSize)
local imageLabel = script.Parent.Parent.WinnerGui.Template.Frame:GetChildren()
imageLabel = imageLabel[i]
imageLabel.Visible = true
imageLabel.Image = content
templatetextlabel:Clone()
templatetextlabel.Visible = true
templatetextlabel.Position = imageLabel.Position - UDim2.new(0.002,0,0,0)
templatetextlabel.Text = "Kills:" .. player.leaderstats.Kills.Value
end
end)
hypotesis
(hypotesis)
August 28, 2020, 1:06pm
#19
your line
local content, isReady = player:GetUserThumbnailAsync(userId, thumbType, thumbSize)
should be
local content, isReady = game.Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
FerbZides
(FerbZides)
August 28, 2020, 1:06pm
#20
but it still doesnt work check above replies
1 Like
FerbZides
(FerbZides)
August 28, 2020, 1:07pm
#21
print the players user id and check if the function really is a valid member of the player service or the player
No UserId is printed. That same error keeps showing up on this line.
local userId = player.UserId