I’m trying to make an invite-friend system that rewards the player by sending a remote to a server script after it is confirmed that the player has invited one of their friends to play.
The issue is I’ve looked through YouTube and the dev forum but could only find tutorials on how to know if the player received the inbuilt Roblox invite GUI. The code below is what I have so far so if anyone could help me with this issue it would be appreciated. (If this is even possible)
function InviteButtonPressed()
local success, result = pcall(
function()
return SocialService:CanSendGameInviteAsync(player)
end
)
if result == true then
SocialService:PromptGameInvite(player)
end
--InviteRemote:FireServer(result)
end
Im Pretty sure this code checks if it was successful in sending. the only issue i see is that the functions arent being called. Ill have to test it to be sure.
Edit:
Can you send more of the code? this doesnt really show much since we dont know the RemoteEvent
The function is connected to InviteBackgroundGui.InviteButton.MouseButton1Click:Connect(InviteButtonPressed)
which is just a GUI button that when clicked runs this function to open the invite GUI.
The remote just sends to a server script that adds a gem to the player with just 5 lines of code.
1st. Use the function game.Players.PlayerAdded:Connect(function()
2nd. Use the Get Friends Async by looping through all the players and the player that just joined.
If they are friends, then reward the user. To make this so people can’t abuse it, add a table and add the friends that already joined into it.