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

Why isn't my script that makes it so if you own a gamepass it makes a button viable working?

I have a script that should make it so that if you own a gamepass it makes it so you can see a button on GUI that it by default invisible.

local passId = 646971612 
 
game.Players.PlayerAdded:connect(function(plr)
	if game:GetService("MarketplaceService"):PlayerOwnsAsset(plr, passId) then
		plr.PlayerGui.ChangeColor.Disco.Visible = true 
	end
end)

it works in studio but when I run it in game it doesn't work and I get "ChangeColor is not a valid member of PlayerGui". I am sure it is in there so I am guessing that it has something to do with having FE on? I reread the blog post on stuff working in studio but not in game but nothing helped me. I really don't know what to do so...

Edit: the script is a server script

1 answer

✓ Accepted answer

Yes, this is due to FilteringEnabled barring the server from directly modifying objects on the client. You could do this inside of the button itself :)

local plr = game.Players.LocalPlayer;
local button = script.Parent;
local market = game:GetService("MarketplaceService");
local id = 646971612;

button.Visible = market:PlayerOwnsAsset(plr,id);

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