Stuck on Intermission GUI (Help)

Hey there!

So for my game i need an Intermission GUI, consisting of the following values:

  • Shows any player that has fired a remote event (‘Play’ button)

  • Removes any player that has fired a remote event (‘Back’ button)

  • Shows Player’s name and icon

  • Adds players in order

  • Shifts all player’s frames when a player leaves in order

So everything works except from the fifth value.

Here’s an image of what it looks like when everyone in the game presses play:

The code is a little weak and unprofessional but it works just fine.

However, when a player (player 2 in this case) does go back to the main menu, this happens:

.

Here’s the code:

local PlayerIntFrame1 = script.Parent:FindFirstChild("PlayerIntFrame1")
local PlayerIntFrame2 = script.Parent:FindFirstChild("PlayerIntFrame2")
local PlayerIntFrame3 = script.Parent:FindFirstChild("PlayerIntFrame3")
local PlayerIntFrame4 = script.Parent:FindFirstChild("PlayerIntFrame4")
local PlayerIntFrame5 = script.Parent:FindFirstChild("PlayerIntFrame5")
local PlayerIntFrame6 = script.Parent:FindFirstChild("PlayerIntFrame6")

game.ReplicatedStorage.PlayerAddedIntermission.OnClientEvent:Connect(function(player)
	if PlayerIntFrame1.Visible == false then
		PlayerIntFrame1.Visible = true
		PlayerIntFrame1.Name = player.Name
		PlayerIntFrame1.PlayerName.Text = player.Name
		PlayerIntFrame1.PlayerImage.Image = game.Players:GetUserThumbnailAsync(player.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size420x420)
	elseif PlayerIntFrame2.Visible == false then
		PlayerIntFrame2.Visible = true
		PlayerIntFrame2.Name = player.Name
		PlayerIntFrame2.PlayerName.Text = player.Name
		PlayerIntFrame2.PlayerImage.Image = game.Players:GetUserThumbnailAsync(player.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size420x420)
	elseif PlayerIntFrame3.Visible == false then
		PlayerIntFrame3.Visible = true
		PlayerIntFrame3.Name = player.Name
		PlayerIntFrame3.PlayerName.Text = player.Name
		PlayerIntFrame3.PlayerImage.Image = game.Players:GetUserThumbnailAsync(player.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size420x420)
	elseif PlayerIntFrame4.Visible == false then
		PlayerIntFrame4.Visible = true
		PlayerIntFrame4.Name = player.Name
		PlayerIntFrame4.PlayerName.Text = player.Name
		PlayerIntFrame4.PlayerImage.Image = game.Players:GetUserThumbnailAsync(player.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size420x420)
	elseif PlayerIntFrame5.Visible == false then
		PlayerIntFrame5.Visible = true
		PlayerIntFrame5.Name = player.Name
		PlayerIntFrame5.PlayerName.Text = player.Name
		PlayerIntFrame5.PlayerImage.Image = game.Players:GetUserThumbnailAsync(player.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size420x420)
	elseif PlayerIntFrame6.Visible == false then
		PlayerIntFrame6.Visible = true
		PlayerIntFrame6.Name = player.Name
		PlayerIntFrame6.PlayerName.Text = player.Name
		PlayerIntFrame6.PlayerImage.Image = game.Players:GetUserThumbnailAsync(player.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size420x420)
	else
		print("Error: PlayerIntFrame'LocalScript'")
	end
end)


game.ReplicatedStorage.PlayerRemovedIntermission.OnClientEvent:Connect(function(player)
	local PlayerIntFrame = script.Parent:FindFirstChild(player.Name)
	PlayerIntFrame.Visible = false
	PlayerIntFrame.PlayerImage.Image = "rbxassetid://3570695787"
	PlayerIntFrame.PlayerName.Text = "ITS ME"
	PlayerIntFrame.Name = "PlayerIntFrame"..PlayerIntFrame.Value.Value
	
	if PlayerIntFrame.Name == "PlayerIntFrame1" then
		local Position = PlayerIntFrame6.Position
		PlayerIntFrame6.Position = PlayerIntFrame5.Position
		PlayerIntFrame5.Position = PlayerIntFrame4.Position
		PlayerIntFrame4.Position = PlayerIntFrame3.Position
		PlayerIntFrame3.Position = PlayerIntFrame2.Position
		PlayerIntFrame2.Position = PlayerIntFrame1.Position
		PlayerIntFrame1.Position = Position
	elseif PlayerIntFrame.Name == "PlayerIntFrame2" then
		local Position = PlayerIntFrame5.Position
		PlayerIntFrame5.Position = PlayerIntFrame4.Position
		PlayerIntFrame4.Position = PlayerIntFrame3.Position
		PlayerIntFrame3.Position = PlayerIntFrame2.Position
		PlayerIntFrame2.Position = PlayerIntFrame1.Position
		PlayerIntFrame1.Position = PlayerIntFrame6.Position
		PlayerIntFrame6.Position = PlayerIntFrame5.Position
	elseif PlayerIntFrame.Name == "PlayerIntFrame3" then
		local Position = PlayerIntFrame4.Position
		PlayerIntFrame4.Position = PlayerIntFrame3.Position
		PlayerIntFrame3.Position = PlayerIntFrame2.Position
		PlayerIntFrame2.Position = PlayerIntFrame1.Position
		PlayerIntFrame1.Position = PlayerIntFrame6.Position
		PlayerIntFrame6.Position = PlayerIntFrame5.Position
		PlayerIntFrame5.Position = Position
	elseif PlayerIntFrame.Name == "PlayerIntFrame4" then
		local Position = PlayerIntFrame3.Position
		PlayerIntFrame3.Position = PlayerIntFrame2.Position
		PlayerIntFrame2.Position = PlayerIntFrame1.Position
		PlayerIntFrame1.Position = PlayerIntFrame6.Position
		PlayerIntFrame6.Position = PlayerIntFrame5.Position
		PlayerIntFrame5.Position = PlayerIntFrame4.Position
		PlayerIntFrame4.Position = Position
	elseif PlayerIntFrame.Name == "PlayerIntFrame5" then
		local Position = PlayerIntFrame2.Position
		PlayerIntFrame2.Position = PlayerIntFrame1.Position
		PlayerIntFrame1.Position = PlayerIntFrame6.Position
		PlayerIntFrame6.Position = PlayerIntFrame5.Position
		PlayerIntFrame5.Position = PlayerIntFrame4.Position
		PlayerIntFrame4.Position = PlayerIntFrame3.Position
		PlayerIntFrame3.Position = Position
	elseif PlayerIntFrame.Name == "PlayerIntFrame6" then
		local Position = PlayerIntFrame1.Position
		PlayerIntFrame1.Position = PlayerIntFrame6.Position
		PlayerIntFrame6.Position = PlayerIntFrame5.Position
		PlayerIntFrame5.Position = PlayerIntFrame4.Position
		PlayerIntFrame4.Position = PlayerIntFrame3.Position
		PlayerIntFrame3.Position = PlayerIntFrame2.Position
		PlayerIntFrame2.Position = Position
	else
		print("Error: PlayerIntFrame'LocalScript'")
	end
end)

If i use a UIGradient, the players’ frame sizes are messed up on different devices.

As you can see i’m not the best at scripting.

Any help would be appreciated! :+1:

Why don’t you use a UI Grid Layout ?

Iv’e tried using a UI Grid Layout, but the size of each cell wont be scaled according to what device you’re on (I think that’s how it works)

Did you added constraint? (30 chars)

1 Like

Could you be able to show me how to add a constraint?

I would greatly appreciate any help! :+1:

You could also script it with a stack like implementation

What that could look like
local playerStack={}


function editUiObj(obj, plr)
	if plr then
		obj.Visible = true
		obj.PlayerName.Text = plr.Name
		obj.PlayerImage.Image = game.Players:GetUserThumbnailAsync(plr.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size420x420)
	else
		obj.Visible=false
	end
end


function update()
	for i=1,6 do
		local ui_obj = script.Parent:FindFirstChild('PlayerIntFrame'..i)
		local plr=playerStack[i]

		editUiObj(ui_obj, plr)
	end
end


game.ReplicatedStorage.PlayerAddedIntermission.OnClientEvent:Connect(function(player) -- Add player
	table.insert(playerStack, player)
	update()
end)


game.ReplicatedStorage.PlayerRemovedIntermission.OnClientEvent:Connect(function(player) -- Remove player
	local index=0
	for i,val in pairs(playerStack) do
		if val==player then
			index=i
			break
		end
	end

	table.remove(playerStack, index)
	update()
end)
1 Like

First you need to install this plugin: https://www.roblox.com/library/1496745047/AutoScale-GUI

You will see a red button called add constraint select the ui that you desire and click the button.

You have to do this for each childrens or one of them will not auto scale.

1 Like

Thank you very much! I already have that plugin so i’ll try it out right now.

I really appreciate your help! :+1:

Thanks! I’ll just organise everything into functions.

I really appreciate your help :+1: