Jump to content

Player Name Check


Recommended Posts

Hi

I'd like to lock a function behind the name of the player using it, as a means to prank my friend.

Essentially the function should only trigger if the player's username is as written. I'm looking for the function to trigger when he's using the custom character himself.

I tried these (separately)

if UserToPlayer('namehere') then

if UserToPlayer() == 'namehere' then

if UserToPlayer = ('namehere') then

but none of these seem to work. 

I tried ThePlayer but apparently this one prints random strings of numbers as a means to identify players, but it changes every game.

is there some obvious thing I'm missing?

 

Link to comment
Share on other sites

If you just want to call a function when a certain player joins, you can do this:

AddPlayerPostInit(function(inst)
	if inst.name == 'somename' then
		-- do something
	end
end)

You can check the same variable, inst.name, whenever you're doing something where you have an instance of a player.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...