Why is it not firing the event?

For somereason after it is purchased it is not fireing the server…

script.Parent.MouseButton1Click:Connect(function()
	local MarketplaceService = game:GetService("MarketplaceService")
	local GamepassID = 811273501 -- Change to your Gamepass ID
	local HasPass
	local Gui = script.Parent.Parent.Parent.Parent.Parent.txt -- Change OpenGui to whatever your gui that is going to open is called 
	local Player = game.Players.LocalPlayer
	local success, message = pcall(function()
		HasPass = MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassID)
		game.ReplicatedStorage.twxCash:FireServer()
	end)

	if HasPass then
		game.ReplicatedStorage.twxCash:FireServer()
		Gui.Visible = true
		wait(3) -- You can adjust how long the other frame is open if the player already has the gamepass
		Gui.Visible = false
	else
		MarketplaceService:PromptGamePassPurchase(Player, GamepassID)
	end
end)
1 Like

Is this a game pass or a product?

1 Like

it is a gamepass

1 Like

Try This:

script.Parent.MouseButton1Click:Connect(function()
	local MarketplaceService = game:GetService("MarketplaceService")
	local GamepassID = 811273501 -- Change to your Gamepass ID
	local HasPass
	local Gui = script.Parent.Parent.Parent.Parent.Parent.txt -- Change OpenGui to whatever your gui that is going to open is called 
	local Player = game.Players.LocalPlayer
	
	HasPass = MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassID)
	
	if HasPass then
		game.ReplicatedStorage.twxCash:FireServer()
		Gui.Visible = true
		wait(3) -- You can adjust how long the other frame is open if the player already has the gamepass
		Gui.Visible = false
	else
		MarketplaceService:PromptGamePassPurchase(Player, GamepassID)
	end
end)

1 Like

it works how fireing the server but when you click the button it automaticlty fires the server and not after the player made the purchase

1 Like

Try This

script.Parent.MouseButton1Click:Connect(function()
	local MarketplaceService = game:GetService("MarketplaceService")
	local GamepassID = 811273501 -- Change to your Gamepass ID
	local HasPass
	local Gui = script.Parent.Parent.Parent.Parent.Parent.txt -- Change OpenGui to whatever your gui that is going to open is called 
	local Player = game.Players.LocalPlayer
	local success, message = pcall(function()
		HasPass = MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassID)
		game.ReplicatedStorage.twxCash:FireServer()
	end)

	if HasPass then
		game.ReplicatedStorage.twxCash:FireServer()
		Gui.Visible = true
		wait(3) -- You can adjust how long the other frame is open if the player already has the gamepass
		Gui.Visible = false
	else
		MarketplaceService:PromptGamePassPurchase(Player, GamepassID)
	end
end)
1 Like

sadly, it is not fireing the server

1 Like

Make a server sided script that checks for when a gamepass is purchased, so for example:

local MarketplaceService = game:GetService("MarketplaceService")

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, gamePassId, wasPurchased)
    if wasPurchased and gamePassId == 811273501  then
        -- do the function here
    end
end)
1 Like

It st ill does not work


1 Like

Are you wanting whatever function you’re firing to happen straight after purchase?

1 Like

yes, I want that to happen


1 Like
script.Parent.MouseButton1Click:Connect(function()
	local MarketplaceService = game:GetService("MarketplaceService")
	local GamepassID = 811273501 -- Change to your Gamepass ID
	local HasPass
	local Gui = script.Parent.Parent.Parent.Parent.Parent.txt -- Change OpenGui to whatever your gui that is going to open is called 
	local Player = game.Players.LocalPlayer
	local success, message = pcall(function()
		HasPass = MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassID)
		game.ReplicatedStorage.twxCash:FireServer()
	end)

	if HasPass then
		game.ReplicatedStorage.twxCash:FireServer()
		Gui.Visible = true
		wait(3) -- You can adjust how long the other frame is open if the player already has the gamepass
		Gui.Visible = false
	else
		MarketplaceService:PromptGamePassPurchase(Player, GamepassID)
	end
end)

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, gamepassID, purchaseSuccess)
	--add script here
end)

Hopefully it works for you

1 Like

Using PromptGamePassPurchaseFinished should be working, are there any errors coming up?

1 Like

no there is no erros for some reason

1 Like

also it has indexz to nil MarketplacxeSerivce, on line 20?

1 Like

I don’t know but, you can try that if a person doesn’t have a gamepass, then the prompt shows and if they purchased it, then the player can click the same thing, and they will get the FireServer() thing

Can you send the function that the event is firing on the server side?

local MarketplaceService = game:GetService("MarketplaceService")
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, gamepassID, purchaseSuccess)
	plr.axes.twxCash.Value = true
end)

Is plr.axes.twxCash.Value = true the entire function?

yes it is