Help with getting players and adding Gui

  1. Main Achievement
    When a boss dies, it gives every player a GUI

  2. The Problem
    The gui is only given to the last player who joins

  3. Attempted solutions
    Using tables (but the boss is in replicated storage so it doesnt count players when they join)
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Code:

--// Variables
local Humanoid = script.Parent.Parent:FindFirstChildOfClass("Humanoid")
local BossGui = game:GetService("ReplicatedStorage").BossText:FindFirstChild(script.BossGui.Value):Clone()

--// Getting Player
spawn(function()
	while true do
		wait()
		for i, v in pairs(game.Players:GetChildren()) do
			Player = v
		end
	end
end)

--// Appear
Humanoid.Died:Connect(function()
	BossGui.Parent = Player.PlayerGui
end)

Thanks for any help, it’s highly appreciated!

local Humanoid = script.Parent.Parent:FindFirstChildOfClass("Humanoid")
local BossGui = game:GetService("ReplicatedStorage").BossText:FindFirstChild(script.BossGui.Value)

--// Appear
Humanoid.Died:Connect(function()
	for i,v in pairs(game.Players:GetPlayers()) do
		BossGui:Clone().Parent = v.PlayerGui
	end
end)

Much simpler to do something like that instead