Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Give currency when a users friend joins the game?

Asked by 4 years ago

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

Log in to vote
1
Answered by
p0vd 207 Moderation Voter
4 years ago
Edited 4 years ago

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)
0
Please accept if this helped! p0vd 207 — 4y
Ad

Answer this question