exactly use the server instead of the client
so i parent it to the playergui on server? But i thought the server wasn’t suppose to handle the gui stuff
StarterGui is cloned into each player’s PlayerGui, this lets the server mess with gui safely
with this logic changing StarterGui in game will only effect people who join since they would clone the changes that got made
It’s not which is why you have 2 options
game.Players.PlayerAdded:Connect(function(player)
local PlayerGui = player:WaitForChild("PlayerGui") -- parent ScreenGui's to here
end)
or
-- local script
local newTemplate = blablabladowhateveryouwant
The second one is better because, there really is no reason for the server to be involved.
I made a whole thread about this, the results are you shouldn’t handle “client things” on the server
i don’t understand the 2nd one
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
- Change something in a replicated container on the server (e.g. workspace)
- 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
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