Premium Area Help

In my game there is an area player can go that have premium but go open the entrance of the area a wall will disappear quickly, the problem is that the wall is letting all players in. Code below

Code

local MarketplaceService = game:GetService(“MarketplaceService”)
local TeleportService = game:GetService(“TeleportService”)
local Players = game:GetService(“Players”)

local teleporter = script.Parent
local showPrompt = true

local placeID_Premium = 6556269769

local function onTeleporterTouch(otherPart)

local player = Players:GetPlayerFromCharacter(otherPart.Parent)
if not player then return end

-- If the user already has Premium, teleport them to the Premium-only place
if player.MembershipType == Enum.MembershipType.Premium then
	
	script.Parent.Touched:Connect(function(hit)
		local human = hit.Parent:FindFirstChild("Humanoid")
		if human ~= nil then
			local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
			if plr.leaderstats.Rank.Value >= 0 then
				script.Parent.Transparency = .5
				script.Parent.CanCollide = false
				wait(.4)
				script.Parent.Transparency = 0
				script.Parent.CanColide = true
			end
		end
	end)

	-- Else, prompt Premium upgrade (use debounce to show it only once every few seconds)
else
	if showPrompt == false then return end
	showPrompt = false
	delay(5, function()
		showPrompt = true
	end)
	MarketplaceService:PromptPremiumPurchase(player)
	warn("Prompted Premium purchase")
end

end
teleporter.Touched:Connect(onTeleporterTouch)

– If needed, use this event to know when the Premium modal is closed
MarketplaceService.PromptPremiumPurchaseFinished:Connect(function(player)
warn(“Premium modal closed”)
end)

– Handle potential Premium purchase from outside the game while user is playing
Players.PlayerMembershipChanged:Connect(function(player)
warn("Player membership changed; new membership is " … tostring(player.MembershipType))
if player.MembershipType == Enum.MembershipType.Premium then
– Teleport player to the Premium-only place
TeleportService:Teleport(placeID_Premium, player)
end
end)

2 Likes

to clarify, do you mean that the door just appears open to them, or are they being teleported aswell?

if player.MembershipType == Enum.MembershipType.Premium then

Move this conditional statement to inside the lambda function connected to the .Touched event of the door/wall. Then have an else statement which closes the door/wall if the conditional check isn’t satisfied, i.e; if the player doesn’t have premium.

2 Likes