I had a gamepass that basically gives you double the amount of money. It seemed to work perfectly fine but then I bought it for myself and it wasn’t working.
Script:
local MarketplaceService = game:GetService("MarketplaceService")
local gamepassId = 29090920
game.ReplicatedStorage.Events.SellGems.OnServerEvent:Connect(function(player)
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamepassId) then
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + player.leaderstats.Gems.Value * 10
print(player.Name.." owns the double coins gamepass") -- this isnt printing
end
end)
I have looked at various articles, checked the gamepass id, and all that
EDIT:
The remote event is firing because I added an “else” event after this and it fires.’
are you sure the remote event is firing? Try adding a print and seeing if it does.
local MarketplaceService = game:GetService("MarketplaceService")
local gamepassId = 29090920
game.ReplicatedStorage.Events.SellGems.OnServerEvent:Connect(function(player)
print("got")
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamepassId) then
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + player.leaderstats.Gems.Value * 10
print(player.Name.." owns the double coins gamepass") -- this isnt printing
end
end)
Please send screenshots of your leaderstats, everything seems to be working fine, please pay attention to these 2 things:
1- You have a working leaderstats.
2- You dont have any parameter in the FireServer() event on the client[ player is automatically there, hence u only need to put it as a argument on the server]
Just tested the script and substituted your gamepassId with one that I own just to confirm and it works fine for me. Just in case, can you confirm that you actually own the gamepass in question? It sounds silly but I’ve made little mistakes like that before. I checked your account and it seems like you don’t own it, although you could be testing on an account that has the gamepass, it’s always good to check.
Other than that, I think the only other potential issue could be that for whatever reason that remote isn’t firing under the assumption you’re not getting any errors.
Okay so it wasn’t on this post becuase I for some reason didn’t think it was important but there was an else statement under the gamepass thing that runs perfectly fine if you don’t own the gamepass
Also I don’t exactly have testing accounts but this isn’t my main account. So I own it but not on this account