Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why my buttons with local script dont make shop frame visible/invisible?

Output says: Players.SashaPro336.PlayerGui.Shop.Frame.TextButton.LocalScript:4: invalid argument #1 to 'Connect' (RBXScriptSignal expected, got function)

The buttons local scripts:

button = script.Parent
shop = game.StarterGui.Shop.Frame

button.MouseButton1Click.Connect(function()
shop.Visible = true     --On other button false--
end)

2 answers

✓ Accepted answer

I see the issue. Simple syntax error. Connect has a colon, not a period.

Also, you must use a local script. Each player has a "PlayerGui" which you must reference.

--Put this LocalScript inside the GUI

button = script.Parent
shop = game.Players.LocalPlayer.PlayerGui.Shop.Frame --You must reference the players PlayerGui

button.MouseButton1Click:Connect(function()
	shop.Visible = true 
end)

Have a good day!

1 comment

0

Thank so much

Hello, this was a mistake I did when I first started out so I am trying to explain it as I would to myself. So basicaly you have defined StarterGui and that is incorrect because the starterGui is just for the server to give the gui's to the players so when someone joins they get something called a PlayerGui and in there all the gui's form starterGui transfer.

Read More here: https://developer.roblox.com/en-us/api-reference/class/PlayerGui I also recommend to watch this video: https://www.youtube.com/watch?v=IFAVIFAHAxY&list=PLhieaQmOk7nK9ob348Yc_PTcIyHjDCnem&index=2&ab_channel=TheDevKing

button = script.Parent -- this will be your TextButton
shop = game.StarterGui.Shop.Frame -- This is actually not the player's gui this is the gui that every player gets to explain it further StarterGui Is basically just a storage for all the gui's and when a player joins he gets a copy of the gui in StarterGui

button.MouseButton1Click.Connect(function()
	
	shop.Visible = true     -- so this is actually referering to StarterGui (server) insted of PlayerGui Witch is for the player // client.
	
end)


-- Solution

button = script.Parent -- TextButton

button.MouseButton1Down:Connect(function(player) -- in this argument we are passing player wich just means we get his game.Players.playernamehere
	
	local OurPlayersGui = player.PlayerGui.Shop.Frame -- this is where the gui for the player is
	
	OurPlayersGui.Viseble = true -- makes it so you can see the frame
	
end)

If there was anything you didnt understand please tell me and I will try better If it did help you please accept my answer.

5 comments

0

Output says: Players.SashaPro336.PlayerGui.Shop.ShopButton.LocalScript:5: attempt to index number with 'PlayerGui'

0

So can you help me

0

I just helped you what do you mean?

0

From line 13-21 is the answer

0

i mean it didnt work output said Players.SashaPro336.PlayerGui.Shop.ShopButton.LocalScript:5: attempt to index number with 'PlayerGui'. Idk what to do

This discussion is preserved as it was. New answers, comments, and votes are closed.