chloeb1
|
  |
| Joined: 28 Sep 2012 |
| Total Posts: 2460 |
|
|
| 27 Sep 2017 01:06 PM |
It works in studio but not when playing, I think it has something to do with the "game.Players.LocalPlayer.PlayerGui.ScreenGui2.Enabled = true" line
Script in ServerScriptService:
local MarketplaceService = game:GetService('MarketplaceService') local devproductid = [ID]
MarketplaceService.ProcessReceipt = function(receiptInfo) for i, player in pairs(game.Players:GetChildren()) do if player.userId == receiptInfo.PlayerId then if receiptInfo.ProductId == devproductid and player then game.Players.LocalPlayer.PlayerGui.ScreenGui2.Enabled = true end end end return Enum.ProductPurchaseDecision.PurchaseGranted end
#code print("this is secretly a bump") |
|
|
| Report Abuse |
|
|
|
| 27 Sep 2017 01:50 PM |
Your assumption about the possible line in question is correct. Because it's from a server-side script, it has no concept of the "local player". Who is the local player when there's 6 people in the game?
Instead, you need to grab the player object using the "receiptInfo.PlayerId" property. Thankfully, the Players service has a method to get the player from the player ID:
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
Now that you have the player, you can do what you want. But note: If you're using FilteringEnabled, then you won't be able to access the PlayerGui, since it only exists for the player (client), not the server. So you will then have to fire a RemoteEvent or RemoteFunction that the client can listen to in order to manipulate the GUI. |
|
|
| Report Abuse |
|
|
chloeb1
|
  |
| Joined: 28 Sep 2012 |
| Total Posts: 2460 |
|
|
| 27 Sep 2017 01:56 PM |
Thanks, I managed to fix it anyway.
Thanks for helping anyways :)
#code print("this is secretly a bump") |
|
|
| Report Abuse |
|
|