Advertisement
Guest User

Multiplayer or Single? Script Roblox

a guest
Oct 19th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1. local SocialService = game:GetService("SocialService")
  2. local Players = game:GetService("Players")
  3. local player = Players.LocalPlayer
  4.  
  5. local function canSendGameInvite(targetPlayer)
  6.     local res, canSend = pcall(SocialService:CanSendGameInvite(targetPlayer))
  7.     return res and canSend
  8. end
  9.  
  10. local function promptGameInvite(targetPlayer)
  11.     local res, canInvite = pcall(SocialService:PromptGameInvite(targetPlayer))
  12.     return res and canInvite
  13. end
  14.  
  15. local function openGameInvitePrompt(targetPlayer)
  16.     local canInvite = canSendGameInvite(targetPlayer)
  17.     if canInvite then
  18.         local promptOpened = promptGameInvite(targetPlayer)
  19.         return promptOpened
  20.     end
  21.     return false
  22. end
  23.  
  24. local function invitePromptClosed(senderPlayer, recipientIds)
  25.     -- Handle custom logic for players invited by sender
  26. end
  27.  
  28. local function inputBegan(input, gameProcessed)
  29.     local inputType = input.UserInputType
  30.     local touch = Enum.UserInputType.Touch
  31.     local mouse1 = Enum.UserInputType.MouseButton1
  32.  
  33.     if inputType == touch or inputType == mouse1 then
  34.         openGameInvitePrompt(player)
  35.     end
  36. end
  37.  
  38. script.Parent.InputBegan:Connect(inputBegan)
  39. SocialService.GameInvitePromptClosed:Connect(invitePromptClosed)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement