Script not detecting mousebutton click

I made a script which detects if a mouse button is clicked ona surface gui. It was working but now it isnt?

while true do
	for _, stand in pairs(game.Workspace.Stands:GetChildren()) do
		for _, frame in pairs(stand.Products.Items.ScrollingFrame:GetChildren()) do
			if frame:IsA("Frame") then
				for _, robuxcost in pairs(frame:GetChildren()) do
					if robuxcost:IsA("TextButton") then
						robuxcost.MouseButton1Click:Connect(function()
							game.ReplicatedStorage.HeyDawhg:FireServer()
							if frame.ItemTypeId.Value == 34 then
								mps:PromptGamePassPurchase(game.Players.LocalPlayer,frame.ItemID.Value)
							else
								mps:PromptPurchase(game.Players.LocalPlayer,frame.ItemID.Value)
							end
						end)

					end
				end
			end
		end

For some reason its not prompting the gamepass and Im not getting any errors? Thanks!

Maybe you have to put in script, try using RemoteEvents

Alright ill try im not sure where ill get the player instance tho or should i send it through a remote everytime?

Yes, that why I highlighted RemoteEvent.

1 Like

For Surface GUIs to detect input from a mouse, They have to be parented to the Screen Gui.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.