Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Give currency when a users friend joins the game?

Recently I have been trying to get a script that gives 5 coins when a user's friend joins. I've been trying to find a way to do this but am unable to.

I am guessing it's a pretty easy script but I have never done something that tries to detect if a user's friend has joined; If someone could help it would highly be appreciated!

1 answer

You can use the :IsFriendsWith() function and you would add the player's UserId as the parameter. But here is the code in your situation:

game.Players.PlayerAdded:Connect(function(player)
	for _,v in pairs(game.Players:GetPlayers()) do
		if v:IsFriendsWith(player.UserId) then
			-- reward coins
		end
	end
end)

1 comment

0

Please accept if this helped!

This discussion is preserved as it was. New answers, comments, and votes are closed.