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

How do you create a script that makes a part disappear locally if owned the gamepass?

I have the concept of doing this, but the concept failed... I tried checking with a local script by checking with userowngamepassasync on the local player user id and yet it doesn't work...

Anyone know what I should do?

1 answer

This should be simple:

You can do this with collision groups or by deleting it

MarketplaceService = game:GetService("MarketplaceService")
GamePassID = --Your Gamepass ID here
script.Parent.Touched:Connect(function(Touch)
	if Touch.Parent.Humanoid then
		local PlayerModel = Touch.Parent:FindFirstAncestorWhichIsA("Model")
		Player = game.Players:GetPlayerFromCharacter(PlayerModel)
		if not Player then return end
		if MarketplaceService:UserOwnsGamePassAsync(Player.UserId,GamePassID then
			(Set the players collision group here so they dont collide with the part.)
		end
	end
end)

Edit by request:

MarketplaceService = game:GetService("MarketplaceService")
GamePassID = --Your Gamepass ID here
game.Players.PlayerAdded:Connect(function(Player)
	if MarketplaceService:UserOwnsGamePassAsync(Player.UserId,GamePassID then
		(do whatever here)
	end
end)

Helpful Links:

https://developer.roblox.com/en-us/api-reference/function/MarketplaceService/PromptPurchase https://developer.roblox.com/en-us/api-reference/function/MarketplaceService/UserOwnsGamePassAsync

Please consider marking this as the answer if you found this helpful.

3 comments

0

It is much better if CollisionGroups are applied along with Region3 to appropriately make a VIP zone.

0

How would you do this without a on touched and just when a player loads into the game?

0

That should do it for you itadakimasu

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