Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

when you buythe gamepass, the script wont destroy a textbutton why does the function not work?

I want it to make the button get destroyed but it isn't working.

local gamepass = 10384087
	local marketplace = game:GetService("MarketplaceService")
	 
	function yes()
	        local Player = game.Players.LocalPlayer
	        if marketplace:PlayerOwnsAsset(Player, gamepass)  then
		           script.Parent.Parent.Parent.KF.CH2:Destroy()
	        end
	    end
	script.Parent.MouseButton1Click:Connect(yes)

Please help!!

1 answer

✓ Accepted answer

This should work:

local Player = game.Players.LocalPlayer
local Id = Player.UserId
script.Parent.MouseButton1Click:Connect(function()
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Id, 10384087) then
		script.Parent:Destroy()
	else
		print("no")
	end
end)

Remember to check your coding: You put PlayerOwnsAsset instead of UserOwnsGamePassAsync.

And another thing, you don't put player:

local Player = game.Players.LocalPlayer
if marketplace:PlayerOwnsAsset(Player, gamepass)  then --Wrong

You put the player's UserId always.

Hope this helps! :)

1 comment

0

Thank you!!

This discussion is preserved as it was. New answers, comments, and votes are closed.