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

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

Asked by 7 years ago
Edited 7 years ago

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

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

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);
Ad

Answer this question