I am needing to make a _G variable that can hold the players name and then use the print statement in another script.. Can you help?
✓ ANSWER ACCEPTED
How to define a players name in a variable?
1 answer
✓ Accepted answer
You can create the variable on PlayerAdded, like this:
local Players = game.Players
Players.PlayerAdded:Connect(function(playerWhoJoined)
_G.LastPlayerToJoinGame = playerWhoJoined.Name
end)
Obviously, this is gonna get overwritten each time someone new joins, so we'll need to build onto this a bit if you wanna store the names of everyone who joins. However if that's the case you're better off just keeping what you need in your PlayerAdded, and passing the player as an argument to other scripts through events for other things you may need.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
In a local or normal script?