Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My script that changes visibility isn't working. Does anyone know the issue?

Asked by
Amsupr -1
6 years ago

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:

1if 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
6end

Thank you, Amsupr

1
Only serverscripts can check if a user owns an asset. Only a localscript can change gui. Use a remote event and your problem should be fixed. RubenKan 3615 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

You need to use RemoteFunction for checking gamepass

01--// ServerScript (put RemoteFunction to ReplicatedStorage and change name to CheckGamePass)
02checkGamePass = game.ReplicatedStorage.CheckGamePass
03function checkGamePass.OnServerInvoke (plr,ID)
04return game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,ID)
05end
06 
07--// LocalScript
08if game.ReplicatedStorage.CheckGamePass:InvokeServer(GamePassID) then
09    script.Parent.Selectable = false
10    script.Parent.Text = '--'
11    script.Parent.Parent.Owned.Visible = true
12else
13    script.Parent.Parent.Owned.Visible = false
14end
0
thank you :) Amsupr -1 — 6y
Ad

Answer this question