How to make a certain player get certain points?

Hey Scripters, I already made a leaderstats and called it “Tickets” but I want it so when my friend (id) joins he gets 1B Tickets. I have no idea how to work with that. Of course me being the absolute noob I am. I tried taking it to YouTube (pointless) or asking my friends but no one is online. PLEASE HELP ME : (

local id = 111111111111111
if id then
player.leaderstats.Tickets.Value = player.leaderstats.Tickets.Value + 1000000000
2 Likes

or you can maybe try this:

*if player.Name == “you friend’s name” then
player.Tickets = the number of tickets that you want to give to your friend
end

1 Like

Yes but what if my friend changes his name?
Edit: That’s why I use id lol

1 Like

I would not count on usernames. UserId is highly more accurate and flexible than the name. For instance, my ID is always 27881264, but my username can be changed.

if player.UserId == id then
    -- set tickets
end
2 Likes

what? If he change his name that means that he changed his whole account and if he changed his account of course the id is not going to work

2 Likes

No lol you can change your username by spending 1000 robux but you will still have the same id.

2 Likes

oops sorry I didn’t know lol so you should use id

2 Likes

Yes but thank you and @anon81993163 for helping me!

3 Likes

Hey @anon81993163 this script didn’t work. Can you help me?

 local id = 1172203233

if player.UserId == id then
	player.leaderstats.Tickets.Value = player.leaderstats.Tickets.Value + 1000000000
end
2 Likes
game.Players.PlayerAdded:Connect(function(player)
	game.Players.LocalPlayer.UserId == "id" then
		player.leaderstats.Tickets.Value = player.leaderstats.Tickets.Value + 1000000000
	else
end)
2 Likes

What type of script do I make it. Where do I place it?
Edit: It is a regular script in Workspace
Edit 2: @AviaBasil It still doesn’t work for some reason?

1 Like

Probably stupid, but did you replace “id” with your friends Id number?
where did you put it? (by it i mean the script)

1 Like

Of course yes. Script is placed as a regular script in Workspace.
I think I forgot to add the if in my script before the player.

1 Like

I dont think a regular script in Workspace can find the Local player.

1 Like

Put a script inside of ServerScriptService.
U can call it whatever u want or like.
Make sure it’s a normal script and not a local script!

Then put this inside the script:

local id = put your friend’s user id here

game.Players.PlayerAdded:Connect(function(player)
if player.UserId == id then
print(“This player is your friend”)
player.leaderstats.Coins.Value = 1000000000
–set the coins to the stats u have!
end
end)

1 Like

So, LocalScript in StarterGui. I’m guessing?

nvm

I fixed my script onto

game.Players.PlayerAdded:Connect(function(player)
	if player.UserId == "id" then
		player.leaderstats.Tickets.Value = player.leaderstats.Tickets.Value + 1000000000
	end
end)
1 Like
game.Players.PlayerAdded:Connect(function(plr)
     if plr.UserId == 111111111111111 then
           plr:WaitForChild("leaderstats"):WaitForChild("Tickets").Value += 1000000000
     end
end)

Put this code inside a script in server script service. Good luck!

2 Likes

If somebody said a solution click the solution button on their comment so people know your problem is solved.

2 Likes

If your using the examples provided by @lifacy and @alliedoeihoialt, you can place them as regular scripts in server script service as @alliedoeihoialt Fixed his to use the added player!

1 Like