This seems like an unusual method, have you tried using RemoteEvents? It looks like it’d help you in this scenario, if you’re wanting to replicate the Gui to all clients
When the game starts, everything in the StarterGui is cloned in player.PlayerGui.
So in your script changing game.StarterGui to player.PlayerGui should fix the issue.
Since everyone above me is saying the StarterGui clones the Ui into the PlayerGui which is inside the player (this is true by the way), you’ll need to get the Ui inside the player while the player is being added. Getting it from StarterGui works, but it shows it to everyone in the game once it is executed I think.
That won’t be replicated across every client though if it’s a PlayerDeath screen & the text is changing for that certain player to die, which wouldn’t make sense
Again, RemoteEvents would be something to look into: They can be used from server-client transportation
--Your script
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
print(player.Name .. " has died!")
Event:FireAllClients(character.Name)
end)
end)
end)
--LocalScript inside your Gui
local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local DeathText = PlayerGui:WaitForChild("PlayerDeath").TextLabel
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
Event.OnClientEvent:Connect(function(VictimName)
DeathText.Visible = true
DeathText.Text = VictimName.." has died!"
DeathText.Boom.Playing = true
end)
Correct me if I’m wrong, but this wouldn’t be very handy server sided. It is most likely he needs to use Remote Events/Functions for Server-Client communication.
Also (don’t quote me on this, I’ve not worked with UI for quite a while.)
Changing it on the StarterGui will not change on the client. Every time a player joins the StarterGui is replicated to the client. Meaning the client does not fetch new changes that happen in StarterGui. Think of StarterGui as a starting template; but the template always has to be changed on the client.
Probably in this case. I am not too experienced with using events/functions since they hurt my head trying to understand the client side of them, but yes.