Ok so basically this is a section of my script that is for a gamepass gui script. I want this to make a textlabel visible if they own the gamepass, but it's not becoming visible for me. I'm new to scripting so an explanation would be helpful too!
Here:
1 | if game:GetService( "MarketplaceService" ):UserOwnsGamePassAsync(player,productId) then |
2 | script.Parent.Selectable = false |
3 | script.Parent.Text = '--' |
4 | script.Parent.Parent.Owned.Visible = true |
5 | else script.Parent.Parent.Owned.Visible = false |
6 | end |
Thank you, Amsupr
You need to use RemoteFunction for checking gamepass
01 | --// ServerScript (put RemoteFunction to ReplicatedStorage and change name to CheckGamePass) |
02 | checkGamePass = game.ReplicatedStorage.CheckGamePass |
03 | function checkGamePass.OnServerInvoke (plr,ID) |
04 | return game:GetService( "MarketplaceService" ):UserOwnsGamePassAsync(plr.UserId,ID) |
05 | end |
06 |
07 | --// LocalScript |
08 | if game.ReplicatedStorage.CheckGamePass:InvokeServer(GamePassID) then |
09 | script.Parent.Selectable = false |
10 | script.Parent.Text = '--' |
11 | script.Parent.Parent.Owned.Visible = true |
12 | else |
13 | script.Parent.Parent.Owned.Visible = false |
14 | end |