You are checking if the service Players's Name property is equal to yours. In order to get your idea working, you would have to keep track of all entrances. Therefore, you would want to use a RBXScriptSignal or event to run your check.
The PlayerAdded event will be best in this context... However, it doesn't work as expected in LocalScripts, so you would have to make sure that it's in a regular (server) script.
game.Players.PlayerAdded:connect(function (player)
end)
then, you could check if the name of the player matches yours.
if player.Name == 'mine' then
end
finally, you would want to actually clone the gui from somewhere other than StarterGui, into the player's or everyone's PlayerGui. Altogether, your script should look something like this..
local storage = game:GetService('ReplicatedStorage')
local guiFile = storage:WaitForChild('RegularGuy')
local name = 'mine'
game.Players.PlayerAdded:connect(function (player)
if player.Name == mine then
local gui = guiFile:clone()
gui.Parent = player:WaitForChild('PlayerGui')
for i, peer in ipairs(game.Players:GetPlayers()) do
gui.Parent = peer:WaitForChild('PlayerGui')
end
end
end
1 comment
Please help.