Purchase Prompt Doesn't Show Up After Its Activated Once

I’ve been making a purchase prompt for my game, and the issue is that the prompt only comes up once. There are no errors, what do I do?

As seen in the video below, after clicking on the purchasable item, the prompt comes up, but after clicking off, whenever clicking on the purchasable item, the prompt doesn’t come up again.

Cancel Button Script

local Button = script.Parent
local BuyFrame = script.Parent.Parent
Button.MouseButton1Down:Connect(function(player)
	BuyFrame:TweenPosition(UDim2.new(0.332, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, 2)

	BuyFrame.Parent.BuyFrameBackgroundFrame.Visible = false
end)

The Script Inside of the ViewportFrame items that lets the prompt come up

local shopItemPromptRemote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvents"):WaitForChild("shopItemPrompt")
local Button = script.Parent

Button.MouseButton1Down:Connect(function(player)
	shopItemPromptRemote:FireServer(script.Parent)
end)

The Prompt Remote Event Script

shopItemPromptRemote.OnServerEvent:Connect(function(player, itemToBeBrought)
	local BuyFrame = player.PlayerGui.ShopGui:WaitForChild("BuyFrame")
	local BuyFrameBackground = player.PlayerGui.ShopGui:WaitForChild("BuyFrameBackgroundFrame")
	local itemCost = itemToBeBrought.Cost.Value

	if player.leaderstats.Studs.Value >= itemCost then
		if itemToBeBrought.ItemType == "killSounds" then
			BuyFrame.Position = UDim2.new(0.332, 0, 1, 0)

			BuyFrame.Visible = true
			BuyFrameBackground.Visible = true

			BuyFrame:TweenPosition(UDim2.new(0.332, 0, 0.248, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, 2)

			itemCost = AddComma(itemCost)

			BuyFrame.BuyText.Text = "Would you like to buy the item "..itemToBeBrought.Name.." for "..tostring(itemCost).." studs?"
			BuyFrame.BalanceText.Text = "Your balance after this transaction will be "..tostring(player.leaderstats.Studs.Value - itemCost).." after this purchase."
		end
	elseif player.leaderstats.Studs.Value < itemCost then
		BuyFrame.Visible = true
		BuyFrameBackground.Visible = true
		
		BuyFrame.BuyButton.Visible = false
		BuyFrame.CancelButton.Text = "Ok..."
		BuyFrame.BalanceText.Visible = false
		BuyFrame.BuyText.Text = "You do not have enough Studs to purchase the item "..itemToBeBrought.Name..", please come back later br0kie."
	end
end)
1 Like

What do you mean it only shows up once?

1 Like

My bad, forgot to provide a video. Look up for more details, as I’ve updated the post.

1 Like

I HAVE NO IDEA WHY THE QUALITY IS THAT BAD

Give me a second

1 Like

@AlternativeOrNot

I’ve posted the video on there.

1 Like

You don’t make Frame visible back again. It is here, it is just not visible.

1 Like

But the frame is made visible in the server script again?

1 Like

No. It is not.
Should be

shopItemPromptRemote.OnServerEvent:Connect(function(player, itemToBeBrought)
	local BuyFrame = player.PlayerGui.ShopGui:WaitForChild("BuyFrame")
	local BuyFrameBackground = player.PlayerGui.ShopGui:WaitForChild("BuyFrameBackgroundFrame")
	local itemCost = itemToBeBrought.Cost.Value

	BuyFrame.Visible = true
	BuyFrameBackground.Visible = true

	if player.leaderstats.Studs.Value >= itemCost then
		if itemToBeBrought.ItemType == "killSounds" then
			BuyFrame.Position = UDim2.new(0.332, 0, 1, 0)

			BuyFrame:TweenPosition(UDim2.new(0.332, 0, 0.248, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, 2)

			itemCost = AddComma(itemCost)

			BuyFrame.BuyText.Text = "Would you like to buy the item "..itemToBeBrought.Name.." for "..tostring(itemCost).." studs?"
			BuyFrame.BalanceText.Text = "Your balance after this transaction will be "..tostring(player.leaderstats.Studs.Value - itemCost).." after this purchase."
		end
	elseif player.leaderstats.Studs.Value < itemCost then
		BuyFrame.BuyButton.Visible = false
		BuyFrame.CancelButton.Text = "Ok..."
		BuyFrame.BalanceText.Visible = false
		BuyFrame.BuyText.Text = "You do not have enough Studs to purchase the item "..itemToBeBrought.Name..", please come back later br0kie."
	end
end)
1 Like

Still doesn’t seem to work

1 Like

Go into Players / your player / PlayerGui / ShopGui and check if BuyFrame and BuyFrameBackground are visible or do they have any transparency.
Note: Do it after you pressed the button for the second time.

2 Likes

The BuyFrame is Visible, although it is at a position on its Y axis that makes it unseeable, while the BuyFrameBackground is simply just not visible, but still at the same position.

1 Like

Well then you have to fix that.

1 Like

So basically,
You need to make sure that the beginning of the function, in which the MouseButton1Down is called, sets the Frame’s visibility and position to its original status before the tween is called.

Example:

local Button = script.Parent
local BuyFrame = script.Parent.Parent
Button.MouseButton1Down:Connect(function(player)

BuyFrame.Parent.BuyFrameBackgroundFrame.Visible = true
BuyFrame.Position = UDim2.new() --Put in the coords of the frame where the tween starts

	BuyFrame:TweenPosition(UDim2.new(0.332, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, 2)

	BuyFrame.Parent.BuyFrameBackgroundFrame.Visible = false
end)

Since the local script sets the visibility to false, it would override the server script. The local script takes priority as it is only for the player, while the server script is for general purposes. So, the server script will continue to think the BuyFrame was always in its original location on the server side while the local script is the one changing its properties on the client side.

1 Like