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
 

Help - Gamepass button

Previous Thread :: Next Thread 
JoshROCKS234 is online. JoshROCKS234
Joined: 16 Jan 2013
Total Posts: 62
26 Jun 2017 01:21 PM
So, I am trying to make a button for those who have a gamepass. The button is supposed to be visible to those that have the gamepass, and not visible to those who have the gamepass. But it does absolutely nothing. Here's the code... It's in a localscript and parent is the button itself that is in the ScreenGUI... game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:wait() if ################################################################## then script.Parent.Visible = true else script.Parent.Visible = false end end)
Report Abuse
JoshROCKS234 is online. JoshROCKS234
Joined: 16 Jan 2013
Total Posts: 62
26 Jun 2017 01:21 PM
What the hell.
Report Abuse
JoshROCKS234 is online. JoshROCKS234
Joined: 16 Jan 2013
Total Posts: 62
26 Jun 2017 01:22 PM
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:wait() if ################################################################## then script.Parent.Visible = true else script.Parent.Visible = false end end)
Report Abuse
JoshROCKS234 is online. JoshROCKS234
Joined: 16 Jan 2013
Total Posts: 62
26 Jun 2017 01:23 PM
Well can someone help me anyways even with ROBLOX being moronic and hashtagging my code? Freaking stupid.
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
26 Jun 2017 01:26 PM
Since it's in a local script, there's no reason for you to be using the PlayerAdded event. Local scripts run on the actual computer of the player. Therefore, you can just access the local player directly using game.Players.LocalPlayer.

Here's what you could do:


local gamepassId = 000000
local hasGamepass = game:GetService("MarketplaceService"):PlayerOwnsAsset(game.Players.LocalPlayer, gamepassId)

script.Parent.Visible = hasGamepass
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
26 Jun 2017 01:27 PM
But as a good rule of thumb, you shouldn't trust the client/local player. Therefore, when the player clicks the button, you should use a RemoteFunction to have the server verify that the player has the gamepass. It could literally use the same marketplace code to check, but it just needs to be done on the server.
Report Abuse
ReaIG is not online. ReaIG
Joined: 10 Apr 2017
Total Posts: 4021
26 Jun 2017 01:30 PM
srs
Report Abuse
JoshROCKS234 is online. JoshROCKS234
Joined: 16 Jan 2013
Total Posts: 62
26 Jun 2017 01:35 PM
O_O Well, hello crazyman32! I used to play your games (especially Freeflight) a lot when I first joined...

Thanks for the help! It worked as expected!
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