I am attempting to create a lobby system. I have all of the game settings and other features working, I just can’t seem to get the joining function down. My problem is when you click join on the lobby, it is supposed to create a ui frame in the owner’s lobby creation Ui, but it creates it for the one who joined. When you click join, it shows the creation Ui, but only for testing.
This is the script that is supposed to fire the event so the Ui is created. The other code changes image id’s on the lobby ui to show the current joined players.
JoinCount = 0
script.Parent.MouseButton1Click:Connect(function()
local Owner = script.Parent.Parent.HostPlayer.HostPlayerName.Value
if script.Parent.Text == "Lobby Is Full" then
else
if JoinCount <= 3 then
if JoinCount == 0 then
local Players = game:GetService("Players")
local Player = game.Players.LocalPlayer
local player = game.Players:FindFirstChild(Player.Name)
local ThumbnailType = Enum.ThumbnailType.HeadShot
local ThumbnailSize = Enum.ThumbnailSize.Size180x180
script.Parent.Parent.GeustPlayer1.Image = Players:GetUserThumbnailAsync(Player.UserId, ThumbnailType, ThumbnailSize)
local StringValue = Instance.new("StringValue")
StringValue.Name = "GeustPlayer1Name"
StringValue.Parent = script.Parent.Parent.GeustPlayer1
StringValue.Value = Player.Name
game.ReplicatedStorage.JoinPlayer:Fire(Owner, JoinCount, player)
JoinCount += 1
elseif JoinCount == 1 then
local Players = game:GetService("Players")
local Player = game.Players.LocalPlayer
local player = game.Players:FindFirstChild(Player.Name)
local ThumbnailType = Enum.ThumbnailType.HeadShot
local ThumbnailSize = Enum.ThumbnailSize.Size180x180
script.Parent.Parent.GeustPlayer2.Image = Players:GetUserThumbnailAsync(Player.UserId, ThumbnailType, ThumbnailSize)
local StringValue = Instance.new("StringValue")
StringValue.Name = "GeustPlayer2Name"
StringValue.Parent = script.Parent.Parent.GeustPlayer1
StringValue.Value = Player.Name
game.ReplicatedStorage.JoinPlayer:Fire(Owner, JoinCount, player)
JoinCount += 1
elseif JoinCount == 2 then
local Players = game:GetService("Players")
local Player = game.Players.LocalPlayer
local player = game.Players:FindFirstChild(Player.Name)
local ThumbnailType = Enum.ThumbnailType.HeadShot
local ThumbnailSize = Enum.ThumbnailSize.Size180x180
script.Parent.Parent.GeustPlayer3.Image = Players:GetUserThumbnailAsync(Player.UserId, ThumbnailType, ThumbnailSize)
local StringValue = Instance.new("StringValue")
StringValue.Name = "GeustPlayer3Name"
StringValue.Parent = script.Parent.Parent.GeustPlayer1
StringValue.Value = Player.Name
game.ReplicatedStorage.JoinPlayer:Fire(Owner, JoinCount, player)
JoinCount += 1
script.Parent.Text = "Full"
end
end
end
end)
This is the script that is receiving the remote event, and SHOULD create the joined player Ui for the Host, it doesn’t
game.ReplicatedStorage.JoinPlayer.Event:Connect(function(Owner, JoinCount, player)
print(script.Parent.HostPlayer.Player.Value)
--if Owner == script.Parent.HostPlayer.Player.Value then
if JoinCount == 0 then
script.Parent.Parent.Parent.LobbyCreationUi.Visible = true
script.Parent.Parent.Parent.LobbyListUi.Visible = false
print(player.Name.." Has Joined The Lobby")
print(game.Players.LocalPlayer.Name)
local GeustPlayer1 = game.Lighting.GeustPlayer1:Clone()
GeustPlayer1.Parent = script.Parent
local Players = game:GetService("Players")
local ThumbnailType = Enum.ThumbnailType.HeadShot
local ThumbnailSize = Enum.ThumbnailSize.Size180x180
GeustPlayer1.ImageLabel.Image = Players:GetUserThumbnailAsync(player.UserId, ThumbnailType, ThumbnailSize)
local StringValue = Instance.new("StringValue")
StringValue.Name = "GeustPlayer1Name"
StringValue.Parent = GeustPlayer1
StringValue.Value = player.Name
elseif JoinCount == 1 then
print(player.Name.." Has Joined The Lobby")
local GeustPlayer2 = game.Lighting.GeustPlayer2:Clone()
GeustPlayer2.Parent = script.Parent
local Players = game:GetService("Players")
local ThumbnailType = Enum.ThumbnailType.HeadShot
local ThumbnailSize = Enum.ThumbnailSize.Size180x180
GeustPlayer2.ImageLabel.Image = Players:GetUserThumbnailAsync(player.UserId, ThumbnailType, ThumbnailSize)
local StringValue = Instance.new("StringValue")
StringValue.Name = "GeustPlayer1Name"
StringValue.Parent = GeustPlayer2
StringValue.Value = player.Name
elseif JoinCount == 2 then
print(player.Name.." Has Joined The Lobby")
local GeustPlayer3 = game.Lighting.GeustPlayer3:Clone()
GeustPlayer3.Parent = script.Parent
local Players = game:GetService("Players")
local ThumbnailType = Enum.ThumbnailType.HeadShot
local ThumbnailSize = Enum.ThumbnailSize.Size180x180
GeustPlayer3.ImageLabel.Image = Players:GetUserThumbnailAsync(player.UserId, ThumbnailType, ThumbnailSize)
local StringValue = Instance.new("StringValue")
StringValue.Name = "GeustPlayer1Name"
StringValue.Parent = GeustPlayer3
StringValue.Value = player.Name
end
--end
end)
I have searched on the forum posts, it seems nobody else has this same problem.