Check if user ownes gamepass

For somereason the script is not checking if the user owns the gamepass… End of script ish


script.Parent.MouseButton1Click:Connect(function()
	local MarketplaceService = game:GetService("MarketplaceService")
	local GamepassID = 811991574 -- Change to your Gamepass ID
	local HasPass
	local Player = game.Players.LocalPlayer
	local Event = game.ReplicatedStorage.Equip.InvisAxe
	
	if axetype.Value == true then
		if script.Parent.Parent.Equiped.Value == false then
				print("asd")
				script.Parent.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
				script.Parent.UIStroke.Color = Color3.fromRGB(221, 0, 0)
				script.Parent.Text = "UNEQUIP"
				unequipall()
				ClearTools()
				GiveTool()
				script.Parent.Parent.Equiped.Value = false
				script.Parent.ImageLabel.Visible = false
		else
				script.Parent.Parent.Equiped.Value = false
				script.Parent.ImageLabel.Visible = false
				print("hgas")
				script.Parent.BackgroundColor3 = Color3.fromRGB(0, 221, 255)
				script.Parent.UIStroke.Color = Color3.fromRGB(0, 169, 221)
				script.Parent.Text = "EQUIP"
				ClearTools()
			
		end
	else
		if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassID) then
			print("asda")
			Event:FireServer()
		else
			MarketplaceService:PromptGamePassPurchase(Player, GamepassID)
			print("bas")
		end	
	end
	
	
end)


Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer

Why are you checking if they have the gamepass on the client? This is so unsafe! Do it on the server.

ill try that

it still does not work…

Event.OnServerEvent:Connect(function(plr)
	if MarketplaceService:UserOwnsGamePassAsync(plr.UserId, GamepassID) then
	plr.axes.Invisaxe.Value = true
	ReplicatedStorage.OnJoin.Invisaxe1:FireClient()
	else
		MarketplaceService:PromptGamePassPurchase(plr, GamepassID)
	end
end)

Do you own the gamepass? Just making sure. Also, Is it a gamepass?

i delted it form my inventory so it could make the purchased