Okay so I'm making a code that basically changes the name of a script when a player joins. The script name is Player1 but when the player joins I want the script to be the players name instead. Here is the code I have (Below) but it in no way shape or form works...I should note I have 2 scripts like this which is why I need values so that if player1 has already been named a.k.a player1 has joined then it will rename player2 script instead of player1. Thanks, if you have any questions just ask. Any wiki links, or source code would be awesome!
----------------------------------------------------------------------------------------------------
--Insert VARIABLES Below
----------------------------------------------------------------------------------------------------
Player1named = game.Workspace.Player1.Named.Value
Playersonline = game.Workspace.PlayerCount.PlayersOnline.Value
local Players = game:GetService("Players")
----------------------------------------------------------------------------------------------------
print("Player 1 script working")
repeat wait()
function onPlayerAdded(player)
if Player1named == false then
print("Player 1 not online, changing this")
game.Workspace.Player1.Name = player.Name
Player1named = true
elseif Player1named == true then
print("Player 1 already online")
return
end
end
until Playersonline == 2
Players.PlayerAdded:connect(onPlayerAdded)

2 comments
Why do you want to do this? This is almost certainly a really bad design choice.
I need it for the card game I'm working on.