Surface Gui Button not clicking

Hello there, Im making a game where you can donate to players from their booth. I have a script in StarterPlayerScripts where it detects if the player has clicked the gamepass. However it only works on a certain stand and no other stands. I have tested it ingame but it still doesnt work.

Here is the StarterPlayerScript:

local mps = game:GetService(“MarketplaceService”)

while wait(1) do
for _, stand in pairs(game.Workspace.Stands:GetChildren()) do
for _, frame in pairs(stand.Products.Items.ScrollingFrame:GetChildren()) do
if frame:IsA(“Frame”) and frame then
frame.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

Any help please. Thanks.

Is the SurfaceGui parented in the Player’s PlayerGui?

No because it wont work because I have multiple stands

Well it needs to be parented otherwise interaction UIs wouldn’t work. And ViewportFrames.

In the meantime, if you’re sure it’s a script issue, what exactly doesn’t work?

This is another script which changes the values How would I parent the template to the surface gui

for _, item in pairs(allItems) do
	local frame = script.Template:Clone()
	frame.ItemID.Value = item["Item"]["AssetId"]
	frame.Cost.Value = item["Product"]["PriceInRobux"]
	frame.ItemTypeId.Value = item["Item"]["AssetType"]
	frame.RobuxCost.Text = "$"..tostring(item["Product"]["PriceInRobux"])
	frame.Parent = stand.Products.Items.ScrollingFrame
end

end

Only a certain stand works though thats the problem, as in I can donate one but not any other.

I think the stand in pairs finds a single stand

Fixed it! It works now . Changed the script

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