My GUI wont show up?

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.

1 Like

I dont think Mouse1Click is a valid event. If this is a GuiButton (TextButton or ImageButton), did you mean to do MouseButton1Click

3 Likes

oop, yeah I meant MouseButton1Click. I didn’t notice that. Thanks!

2 Likes

actually its still not working.

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.

What type of script is this? Maybe you can take some inspiration from The example given here?

1 Like

“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 :confused:

1 Like

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 :frowning:)

2 Likes

Yes, tipe “MouseClick” not “MouseButton1Click”. “MouseButton1Click” is for GUI buttons.

2 Likes

this is a gui button like problem I would say.

1 Like

thank you!
:slightly_smiling_face:

What do you mean? Is it a part or GUI? Now I don’t more know anything?!

1 Like

yes its part of a gui. here ill send a pic

Ohhh… OK! I thinked it were a part… Sorry!

1 Like

494db99ae132ba87c30c3dfe94033e97
its alright!

1 Like

OK! Then I don’t know :confused: I work easier, not with Scripts like this… How I said, I’m a noob. But I tried. So sorry! I hope you know it soon!! Sorry :confused:

1 Like

it’s alright! Thank you! :slightly_smiling_face:

1 Like

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)
1 Like

oh yeah. I fixed the MouseButton1Click a while ago but I didn’t notice the space. I’ll try it out and see if it works. Thanks!

:slight_smile: 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)

1 Like