Can someone help me with this problem?

hi readers can you help me? i have a problem with this script. where when Player buy Trail and their money is not enough, then my Games will offer to buy money to Player. but the mistake when i have bought Trail messages to buy money suddenly appear when it should not appear because i have bought trail.

Video

so what’s wrong with this script???

local MPS = game:GetService("MarketplaceService")

local MarketplaceService = game:GetService("MarketplaceService")

local productID = 1923524272


local function displayInsufficientFundsMessage()
	local message = script.Parent.A.Info.Frame.TrailName
	message.Text = "Money Not Enough"
end

script.Parent.A.Info.Frame.Buy.MouseButton1Down:Connect(function()
	local Trail = script.Parent.A.Info.Frame.TrailName.Text
	if game.ReplicatedStorage.Trails:FindFirstChild(Trail) then
		local Player = game.Players.LocalPlayer
		local Currency = Player.leaderstats[game.ReplicatedStorage.Trails.Curency.Value]
		local Price = game.ReplicatedStorage.Trails[Trail].Price
		if Price:FindFirstChild("ID") and Player.Trails[Trail].Value == false then
			MPS:PromptGamePassPurchase(Player,Price.ID.Value)
		else
			if Currency.Value < Price.Value then
				MarketplaceService:PromptProductPurchase(Player, productID)
			else

		end
		script.Parent.BuyEvent:FireServer(Trail)
	 end
	end
end)

I don’t understand what you mean, I’m here asking for help, what’s wrong with me???

Theres nothing wrong, they are a troll please ignore them. Im looking at your code Ill be back to you in a sec with anything I find!

1 Like

Ok from looking at your code, it prompts them to buy a gamepass, which I assume returns false, in the else case you check if they dont have enough currency, but you never check if they own the item.

Reference:

This runs even if they own the trail.

So simple fix, just check if the player owns the trail right there and you should be good I think.

1 Like

@mod
oh do we have to report ourselves to the Moderation Team?

dont worry, I already reported them, the mods are on break rn so we’ll have too wait for them to come back

ok good your answer is very helpful for me, thank you the problem has been solved

1 Like

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