generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Dev Product Handler [Help]

Previous Thread :: Next Thread 
chloeb1 is not online. 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
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image