Server to client remote event

So I made a gamepass and I want to run a remote event from the server to the client. But it doesnt run the code on the client. Any help is very appreciated!

--server
MPS.PromptGamePassPurchaseFinished:Connect(function(player, purchasepassId, purchaseSuccess)
	warn("server")
	if purchaseSuccess == true and purchasepassId == gamepassID then
		warn("firing server")
	client:FireClient(player, purchaseSuccess)
	end
end)
--works fine
--client
client.OnClientEvent:Connect(function(player, purchasesuccess)
	warn("passed client")
	passowner = purchasesuccess
end)
--doesn't work

In the client script, when it’s called, the first argument which is passed from server to a specified client isn’t the player; so the ‘purchasesuccess’ value you attempted to pass is ‘nil’, because the player object isn’t passed from server-to-client. Hope I’ve been clear. <3

So in this case, it would be:

client.OnClientEvent:Connect(function(purchasesuccess)
	warn("passed client")
	passowner = purchasesuccess
end)

I suggest you to pass around additional info there, if you’re still new into using server to client and viceversa communications. Happy coding!

Thanks for the help! But that doesn’t seem to be the problem. For some reason the OnClientEvent function isn’t running. Would love to hear from you again!

You need to put these i believe:
https://developer.roblox.com/en-us/api-reference/function/MarketplaceService/UserOwnsGamePassAsync

https://developer.roblox.com/en-us/api-reference/event/MarketplaceService/PromptPurchaseFinished
like decrypteds said:

well i think it helped you

1 Like