In order to keep my game safe I would like to delete a ScreenGui that I called VIPGui if a player does not own a game pass. If they do own the game pass then I would like the Gui to not be deleted, if that makes sense. I used a local script and inserted it into the VIPGui. I wrote the following:
local MS = game:GetService("MarketplaceService") local gamepassid = 0 (I did insert my real game pass id in studio) if MS:UserOwnsGamePassAsync(game.Players.LocalPlayer.userId, gamepassid) == false then
script.Parent:Destroy()
end
It did not work so I did the same thing again:
local MS = game:GetService("MarketplaceService") local gamepassid = 0 if MS:UserOwnsGamePassAsync(game.Players.LocalPlayer.userId, gamepassid) == false then
game.StarterGui.VIPGui:Destroy()
end
It still did not work. I checked the output and it was not giving any feedback? I did not own the game pass so it should have deleted but it did not, and my friend did own the game pass and it dd not delete either, which is good, but I believe it is because it did not work. If anyone could please explain, I would appreciate that! Thanks.
Hello Bulder251,
When a player character loads, things in StarterGui are cloned into that player PlayerGui, so you shouldn't be deleting stuff in the StarterGui if you want them only to be taken away from the player. I also recommend making it so if they have the game pass, you clone it, then put it into their PlayerGui. With that said, I recommend making the GUI a parent of ServerStorage.
local Players = game:GetService('Players') local MarketplaceService = game:GetService("MarketplaceService") local PassID = 1 -- // Your game pass ID Players.PlayerAdded:Connect(function(player) local GuiPath = PATH -- // The path to your GUI you wanted to be cloned | Don't put it in StarterGui if MarketplaceService:UserOwnsGamePassAsync(player.userId, PassID) then local CloneGui = GuiPath:Clone() CloneGui.ResetOnSpawn = false CloneGui.Parent = player.PlayerGui end end)