How do I make it so that “PlayerName” as a variable works in the line of code below, because right now it is throwing an error at me. Any help would be greatly appreciated!
1 Like
You can do game.Players:FindFirstChild(PlayerName)
of course if you do this make sure to check if player exist.
local Players = game:GetService("Players") -- Better practice
local Player = Players:FindFirstChild(PlayerName)
if not Player then return warn("Player doesn't exist") end
1 Like
Instead of game.Players.PlayerName
you can do either:
1)
game.Players[PlayerName]
game.Players:FindFirstChild(PlayerName)
3 Likes
Thanks for the help, this fixed my problem
1 Like