I want to make a gamepass only building that will block players if they don't have the gamepass. If they have the gamepass, it will teleport them in or they will be able to walk through. If they don't have the gamepass, it will block them and not teleport them and also ask to buy the gamepass. How do I do this?
Hello! Try this script. Make sure to put it as a normal script under the part that you want a player to touch to enter the building. Also, change the variable gamepassId
to your gamepass's ID! Set the CFrame.new(x,y,z)
on line 8 to the xyz position you want the player to be teleported to.
local MarketplaceService = game:GetService("MarketplaceService") local gamepassId = 5433172 -- IMPORTANT: Replace this with your gamepass's ID! script.Parent.Touched:Connect(function(touchedBy) if touchedBy.Parent:FindFirstChild("Humanoid") ~= nil then local ownsPass = MarketplaceService:UserOwnsGamePassAsync(game.Players[touchedBy.Parent.Name].UserId, gamepassId) if ownsPass then touchedBy.Parent:MoveTo(Vector3.new(0,0,0)) end end end)
If you have issues with this, please let me know!