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

Can somebody help me with my gamepass gui script? it works but it has flaws.

I made a script for a gamepass gui it works but it has flaws, people that do not own the gamepass can see the gui and use it. heres the script:

local MS = game:GetService("MarketplaceService") local gamepassid = if MS:UserOwnsGamePassAsync(game.Players.LocalPlayer.userId, gamepassid) == false then

script.Parent:Destroy()

end

1 answer

Try to make the Script wait for some confirmation that the player has been loaded, for example, wait for his character to be added.

local MS = game:GetService("MarketPlaceService")
local GamePassId = -- GamePass ID.
local Player = game.Players.LocalPlayer

Player.CharacterAdded:Wait()
local HassPass = MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, GamePassId)
if not HassPass then -- or HassPass == false
	script.Parent:Destroy()
end

But I suggest that you make the Gui appear to the player if he has the Pass, instead of destroying it if he doesn't.

local MS = game:GetService("MarketPlaceService")
local GamePassId = -- GamePass ID.
local Player = game;Players.LocalPlayer

Player.CharacterAdded:Wait()
local HassPass = MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, GamePassId)
if HassPass then -- or HassPass == true
	script.Parent.Enabled = true -- This is an example
end

If it doesn't work, could you return the error to me? So maybe I can help fix it :)

1 comment

0

They did not work, i don't know why but i went on an alt and the gui was still visible.

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