I made a script which, if a gamepass isn't owned, to prompt the player to buy it. I tested it out on a Roblox Studio server, but after I bought it and I tried to click the button the script is in, it still prompted me to buy it. I was wondering if this was an error in my script or if this will always happen when testing on a Roblox Studio server. Here's my script, located in a TextButton:

ms = game:GetService("MarketplaceService")

script.Parent.MouseButton1Click:Connect(function()
	if ms:UserOwnsGamePassAsync(script.Parent.Parent.Parent.Parent.Parent.UserId, 8885033) and script.Parent.Parent.Parent.Parent.Parent.Info.BonusMusic.Value == false then
		script.Parent.Parent.Parent.Parent.Parent.Info.BonusMusic.Value = true
		script.Parent.Text = "Yes"
	
	elseif ms:UserOwnsGamePassAsync(script.Parent.Parent.Parent.Parent.Parent.UserId, 8885033) and script.Parent.Parent.Parent.Parent.Parent.Info.BonusMusic.Value == true then
		script.Parent.Parent.Parent.Parent.Parent.Info.BonusMusic.Value = false
		script.Parent.Text = "No"
	
	elseif not ms:UserOwnsGamePassAsync(script.Parent.Parent.Parent.Parent.Parent.UserId, 8885033) then
		ms:PromptGamePassPurchase(script.Parent.Parent.Parent.Parent.Parent, 8885033)
	end
end)

(I'd view source since it doesn't seem fit correctly on the website)

2 comments

0

try just using "else" instead of "elseif not"

0

It still seems to happen