So, my friend asked me to make him an invite friend button for his game so I went ahead and did it but for some reason if I run the game or I play the game in the studio or not it wont show up.
Here is the script.
local button = script.Parent
local SocialService = game:GetService("SocialService")
local player = game.Players.LocalPlayer
function onButtonPressed ()
local success, result = pcall (
function ()
return SocialService:CanSendGameInviteAsync(player)
end
)
if result == true then
SocialService:PromptGameInvite(player)
end
end
button.Mouse1Click:Connect(onButtonPressed)
button.TouchTap:Connect(onButtonPressed)
I am still pretty new to scripting so If I did anything wrong please tell me.
because here is the thing. when i run or play the game in studio for example i see the ScreenGUI but I see nothing in it but if I go and click stop and I check, its there.
“Mouse1Click” isn’t right. You must tipe, when you have a part, (make a ClickDetector into) then put a script into and tipe “MouseClick” (for that you must tipe on the top by “local button = script.Parent” make it to: "local button = script.Parent.Parent) sorry for my bad english
If this doesn’t work, dont make a Script into the ClickDetector, make a LocalScript. If it then dont works, then I’m dumb… (I doesn’t do this long scripting… I more script GUIs, so sorry, if I can’t help you )
Your script has some huge issues such as using Mouse1Click instead of MouseButton1Click and also having a space in onButtonPressed (). Here’s the fixed script.
local SocialService = game:GetService("SocialService")
script.Parent.MouseButton1Click:Connect(function()
local plr = game:GetService("Players").LocalPlayer
local success, result = pcall (
function ()
return SocialService:CanSendGameInviteAsync(player)
end
)
if result == true then
SocialService:PromptGameInvite(player)
end
end)
Quick question are you sure it’s in a local script and a part of your button, also… are you sure TouchTap is a thing? I never really head of it, on mobile or small devices, MouseButton1Click has the same affect as it does on PC or Laptop.and even xbox (i think)