How do i clone gui only once for each player in game

actually this makes me think

localscripts run whenever a player joins the game so you could just say GUI.TEXT = NAME with no problems

Ok, do you know what a LocalScript is? If not itā€™s a script that runs on the client (each players machine). Itā€™s meant to handle all ā€œclient thingsā€. Do to the fact itā€™s on the client, the person can technically change any script or any value which is why you never trust values from the client.

In the second option you simply make a local script in StarterPlayerScripts (or any client container)

-- local script
local newTemplate = tradingTemplate:Clone()
newTemplate.Parent = script.Parent -- this would be good if the localscript was inside a ScreenGui
newTemplate:WaitForChild("playerName").Text = player.Name

This code will run independently for each player, the server canā€™t access it and the other clients canā€™t access it.

would it show every players name? And wouldnā€™t it run only once?

it would run for each player silly

No anything done on the client does not replicate to the server, if you want something to replicate to all the clients you either

  1. Change something in a replicated container on the server (e.g. workspace)
  2. Fire a RemoteEvent and use :FireAllClients

i tried that, but it didnā€™t work. It only showed their own name not everyones

game.Players.PlayerAdded:Connect(function(player)
	Remotes.ShowForAllClients:FireAllClients(player)
end)
RP.Remotes.ShowForAllClients.OnClientEvent:Connect(function()
	local newTemplate = tradingTemplate:Clone()
	newTemplate.Parent = script.Parent
	newTemplate:WaitForChild("playerName").Text = player.Name
end)

yea I can see where you messed up with this :joy:
ill let elon explain this

If you are making an overhead Gui (like a billboard Gui in the workspace), in this case it makes the most sense to do it on the server.

anyway I'll tell you what's wrong with the code

On the client script you posted you donā€™t take into account the player object that gets passed through the RemoteEvent, you want to place the GUI in each player character.

RP.Remotes.ShowForAllClients.OnClientEvent:Connect(function(player)
	local newTemplate = tradingTemplate:Clone()
	newTemplate.Parent = player.Character -- 
	newTemplate:WaitForChild("playerName").Text = player.Name
end)

For this case I would do

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        -- put a billboardGui in Player.Character
        local billboard = ReplicatedStorage.template:Clone()
        billboard.Parent = player.Character
    end)
end)

Even though itā€™s technically handling a GUI on the server, I still think itā€™s better because the server replicates the workspace anyway.

maybe a pro will come and say Iā€™m wrong but I donā€™t think so

No because if a player joins it fires the function again

Um I donā€™t think you are fully up to date on the situation. We are talking about a local script.


@NotZylon refer to my last post


lol

itā€™s not a billboardgui though, itā€™s just a frame

I already knew that hehehehehehe

Well then do it however you like,

Overhead GUIā€™s are usually billboard guiā€™s (I think they always are)


@D0RYU pog

Oh ok sorry just got here lol my bad man

nothing to be sorry for
if ur busy then ur busy

(Cant like need to wait 1 hour lol)

but im not sure what i did wrong

Can you send the code so I can see it?

wait what is the current script or scripts you are using for it rn

RP.Remotes.ShowForAllClients.OnClientEvent:Connect(function()
	local newTemplate = tradingTemplate:Clone()
	newTemplate.Parent = script.Parent
	newTemplate:WaitForChild("playerName").Text = player.Name
end)
game.Players.PlayerAdded:Connect(function(player)
	Remotes.ShowForAllClients:FireAllClients(player)
end)