Problem with gamepass

local module = require(game.ServerStorage.SettingsForSci)
local pass = 22467991
local mpService = game:GetService("MarketplaceService")
local haspass	



script.Parent.MouseButton1Click:Connect(function(player)

	local success,message = pcall(function()
		
		
		haspass = mpService:UserOwnsGamePassAsync(player.UserId, pass)	
	end)
	if haspass then
		print("Yes")

	else
		warn("No")
		mpService:PromptGamePassPurchase(player,pass)
	end
	
	
end)


my code ^

Why isn’t this working even though I own the gamepass

problem is MouseButton1Down cant get the player at arguments :frowning:
to fix that! you should check MouseButton1Down in a local script… then fire a remote which is sending the player… then in normal script. get the fired remotes signal. then check if player has gamepass.
hope this heps

Change
script.Parent.MouseButton1Click
to
script.Parent.MouseClick

MouseClick is nothing in lua and thus cant change it

is it a ClickDetector ?
##########

No it is a gui, mouseclick is for click detectors only

MouseButton1Click doesn’t pass player as argument

all you need to do is just fire a remote event just as Rae said

Yea I know I saw that he told me I am trying it out rn

can u explain a bit more what do you want to do ?
MouseButton1Click can only used on client, but considering you are using game.ServerStorage, so
i assume it is server script.

bruh use this add this
1- add script in serverscripts and type this


local pass = 22467991
local mpService = game:GetService("MarketplaceService")
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
		local haspass = mpService:UserOwnsGamePassAsync(player.UserId, pass)	
	if haspass then
		print("Yes")
	else
		warn("No")
		mpService:PromptGamePassPurchase(player,pass)
	end
end)

2 -make RemoteEvent on ReplicatedStorage
3- make button and local script and type this

script.Parent.TextButton.MouseButton1Down:Connect(function()
	local pass = 22467991
	game.ReplicatedStorage.RemoteEvent:FireServer(pass)
end)

like this
image

have fun

Thanks for your help :)))))))))))))))))))))