How to add points once a player has invited their friend?

Hi, I made a button that prompts the invite friends GUI, although I would like to make it so that, once a player has invited one of their friends, they earn 5 Points. This is the code I have right now. How should I modify it so it adds 5 Points?

local button = script.Parent
local SocialService =  game:GetService("SocialService")
local player = game.Players.LocalPlayer

button.MouseButton1Click:Connect(function()
	SocialService:PromptGameInvite(player)
end)
1 Like

Maybe if you can, try to see if a players friend is in game, if they are, then set a remote event that changes the leaderstats point value.

local SocialService = game:GetService(“SocialService”)

game.ReplicatedStorage.PopupFriends.OnServerEvent:Connect(function(player)
SocialService:PromptGameInvite(player)
end)

SocialService.GameInvitePromptClosed:Connect(function(player,ids)
local XPPerInvite = 100
local XPMade = #ids * XPPerInvite

player.leaderstats.XP.Value = player.leaderstats.XP.Value + XPMade

game.ReplicatedStorage.ShowMessage:FireClient(player, #ids, XPMade)

end)

1 Like

Hold on, doe sthis add points when they invite a player or only when that player joins? I don’t really understand this part: game.ReplicatedStorage.ShowMessage:FireClient(player, #ids, XPMade)

Well yes you would need to edit it though for your stats

4 Likes

But I don’t need the last line right? Otherwise, what is its use?

I just tested it in a real Server and it didn’t work, it didn’t invite people.