|
| 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 |
|
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| Joined: 10 Apr 2017 |
| Total Posts: 4021 |
|
| |
|
|
| 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 |
|
|