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

How to make a gui's script not be disabled if player owns a gamepass?

Asked by 5 years ago

I tried doing this on my script no output errors

local id = 4594022
game.Players.PlayerAdded:connect(function(player)
if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, id) then
    script.Parent.Script.Disabled = false
end
end)
0
Instead of disabling/enabling the script, why not disable/enable the gui itself? waifuSZN 123 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

That script wouldn't work because of the way you're checking for passes. I suggest using this instead and looking at Abilities and Bonuses for more information.

local id = 4594022
game:GetService("Players").PlayerAdded:Connect(function(Player)
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, id) then
        script.Parent.Script.Disabled = false -- This would not work if the global script is in the Gui and FilteringEnabled is set to true.
    end
end)

Another thing, is the game FilteringEnabled? If it is this would not work because global scripts do not work in Guis when it is enabled. I suggest using a RemoteEvent instead.

0
It isnt in filteringenabled and i have no idea how remoteevents work. DevelopingUnlimited -6 — 5y
Ad

Answer this question