How Do I Find Players with Their Username in My Game?

So, whenever both players come to the stage my remote function will find two of them and give them a GameTag to see if the player left, reset and showing the UI. I store the usernames in a StringValue and I was wondering if there’s any way to find them and give them the GameTag.

Edit: Here’s how the system works:
LocalScript: Checks if two bool values are true and invokes the remote function
Script: Whenever the remote function is invoked find both of the players and give them a GameTag
LocalScript(for the gui): If the player has GameTag then display them the GUI using PlayerGui.

1 Like
local User1 = game.Players:FindFirstChild(StringValue.Value)
local User2 = game.Players:FindFirstChild(StringValue2.Value)

if User1 and User2 then
-- give players gametag and fire remotefunction
end

2 Likes

Oh, thanks for the response! I’ll be implementing this.
If you’re wondering, yes I am not that good in Lua.

1 Like

I suggest you take some time to understand roblox’s way of working and client/server boundries before you do such scripts.

1 Like

Okay, I am learning it by checking articles in Developer Hub and some tutorials on YouTube. Nevertheless, yes it is very important to learn these and I’m learning them right now!

2 Likes

I’m not really sure what you’re looking for, but I guess this might help.

local Players = game:GetService("Players")
if Players[StringValue1.Value] then --- Checks if Player is in game
--Do something
end