How would I be able to make a premium only door

Thank you for coming to my post:
Basically, when a player without ROBLOX premium collides with a brick, the premium prompt appears. If the user has ROBLOX premium, make them allowed to go thru the brick.
Thanks in advance!

7 Likes

Take a look at this article, it has all the information you need: Engagement-Based Payouts | Documentation - Roblox Creator Hub

You would then use the touched event to tell when a player has collided with the brick.

Edit: If you haven’t seen the Premium Payouts update I recommend checking it out here

4 Likes

I have 0 knowledge in scripting.

4 Likes

Hey there!
You can use this code in a LocalScript to make the brick disappear.

if game.Players.LocalPlayer.MembershipType == Enum.MembershipType.Premium then
    game.Workspace.PremiumDoor:Destroy()
end

Rename “PremiumDoor” to the brick’s name, and make sure the code is in a LocalScript.

If you don’t want the door to be destroyed, put an invisible brick in front of the door, and name it “PremiumDoor”, If doing this, make sure the door is CanCollide = false.

Using this technique, the brick will be destroyed for everyone with premium, allowing them to walk trough without delay.
Everyone without premium cannot go trough, or follow a premium member.

4 Likes

What if I wanted the door to prompt premium purchase if the user didn’t have premium?

Put the code shown below in a Script, this script is placed in ServerScriptService

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local PremiumEvent = game.ReplicatedStorage.RemovePremiumDoor
local showPrompt = true

local function onPremiumDoorTouch(otherPart)
	local player = Players:GetPlayerFromCharacter(otherPart.Parent)
	if not player then return end
	if player.MembershipType == Enum.MembershipType.Premium then
		PremiumEvent:FireClient(player)
	else
		if showPrompt == false then return end
		showPrompt = false
		delay(5, function()
			showPrompt = true
		end)
		MarketplaceService:PromptPremiumPurchase(player)
	end
end

game.Workspace.PremiumDoor.Touched:Connect(onPremiumDoorTouch)

Players.PlayerMembershipChanged:Connect(function(player)
	if player.MembershipType == Enum.MembershipType.Premium then
		PremiumEvent:FireClient(player)
	end
end)

Put the code shown below in a LocalScript, this has to be placed in StarterGui

local PremiumEvent = game.ReplicatedStorage.RemovePremiumDoor
local function OpenPremiumDoor()
    PremiumEvent:Destroy()
    game.Workspace.PremiumDoor:Destroy()
    script.Disabled = true
end

PremiumEvent.OnClientEvent:Connect(OpenPremiumDoor)

Create a RemoteEvent called “RemovePremiumDoor” and place it in ReplicatedStorage

That’s all needed to set it up, for help or the game file I tested things in send me a DM on Discord. Antony.#0001

21 Likes