Button Won't Press

I’m trying to make a button to open my shop. For some odd reason, it won’t even detect when clicked. Help.

 script.Parent.OpenShop.MouseButton1Click:Connect(function()
	print("1")
	script.Parent.Parent.Shop.Frame.Visible = true
end)
--Mobile Open
script.Parent.Close.TouchTap:Connect(function()
		print("2")
	script.Parent.Parent.Shop.Frame.Visible = true
end)```

Note: I am using a mouse to use the button. Nothing printed on the client or server-side.

Can you please attach a screenshot of the Explorer window? I want to see the hierarchy and how the objects are arranged.

1 Like


LocalScript in Interface has the code above.

Which layer is the button on or the zindex.

Open Button Zindex = 2
30charss

Are you sure that nothing is printed, not even the 1 or the 2?
If you can upload that place as .rbxl file here, I can take a look.

The button itself should have the highest zindex. So for example if your button zindex is 1 and the background is 2 you can’t click the button because the top layer is blocking the bottom layer. But if you made the zindex of the button 3 you would click on the button because the button layer is higher than the background layer.

Also is the position of the shop frame on your screen or is it on the side?

@slothfulGuydevfourm.rbxl (26.8 KB)
@adminaccount58
The shop UI is on my screen. Also the zindex was already higher than everything. (I tried with 3 just in case)

Based on the hierarchy your script will fail. Which LocalScript is your original post referring to?

If it’s the first, it’ll fail when trying to index Close button, and if it’s the second it’ll fail when trying to index the OpenShop button.

1 Like

The first script is the one in the original post. It detects OpenShop, not Close.

Okay, then you need to remove the second part of the script that references Close then… This error also shows up in the Output so check that before posting on the forum for quick solutions.

Example of using the Output to find the error:
image

1 Like

Got the same output to. (char30)

Are you trying also to make a close button?

@adminaccount58 It is an open button. May make it a close button in the future but right now I need to open the shop.
@BanTech The second part of the script is for mobile. I changed it just in case and I still got no output.

script.Parent.OpenShop.MouseButton1Click:Connect(function()
	print("1")
	script.Parent.Parent.Shop.Frame.Visible = true
end)
--Mobile Open
script.Parent.OpenShop.TouchTap:Connect(function()
		print("2")
	script.Parent.Parent.Shop.Frame.Visible = true
end)```

^^^Updated Script

Please use three backticks ``` to format code on the forum, not a quote block as it doesn’t preserve the indentation or code highlighting.

And your updated code works correctly, as you are now referencing a button that exists. Feel free to mark the correct answer with the solution checkmark.

1 Like

I’m not sure if I’m being misunderstood but the button when I click it doesn’t print “1” or open the UI.

Yes it does. I pasted the code you just put in your last reply and it works fine.

Be sure to click Play Solo button or publish and play your game to get the latest changes.


Edit: More info to try to explain.

The original problem is as I described in my first reply - you referenced Close instead of OpenShop, and Close didn’t exist in that Gui.

Your current problem is that you haven’t published or are testing an old version in studio with the original code, not the new code you just wrote. Stop any testing and then click Play again.

1 Like

Honestly, I’m getting very confused with this code (I’m guessing you are too).
I tried it again, tried it in the actual Roblox game and it won’t work. I’m going to see if there is part of the drag-and-drop scripts that is causing this. Videos:
robloxapp-20200429-1157257.wmv
robloxapp-20200429-1201254.wmv

I don’t think I am confused with the code. It’s very simple and your code works.

Here is the place file you uploaded, with your code pasted into it directly from the DevForum. I haven’t changed anything else. Open this place and click the Play Solo button ( image ), or publish and play the game.

devfourm with your code pasted in.rbxl (28.4 KB)

1 Like