Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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:

if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player,productId) then
	script.Parent.Selectable = false
	script.Parent.Text = '--'
	script.Parent.Parent.Owned.Visible = true 
	 else script.Parent.Parent.Owned.Visible = false
end

Thank you, Amsupr

1 comment

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.

1 answer

✓ Accepted answer

You need to use RemoteFunction for checking gamepass

--// ServerScript (put RemoteFunction to ReplicatedStorage and change name to CheckGamePass)
checkGamePass = game.ReplicatedStorage.CheckGamePass
function checkGamePass.OnServerInvoke (plr,ID)
return game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,ID)
end

--// LocalScript
if game.ReplicatedStorage.CheckGamePass:InvokeServer(GamePassID) then
	script.Parent.Selectable = false
	script.Parent.Text = '--'
	script.Parent.Parent.Owned.Visible = true 
else
	script.Parent.Parent.Owned.Visible = false
end

1 comment

0

thank you :)

This discussion is preserved as it was. New answers, comments, and votes are closed.