How do I make a premium-only teleporter within the same experience?

So I’m using the script provided by ROBLOX where if you own premium you get teleported to a specific place and if you don’t it shows the purchase prompt to buy premium so that you can get access to the teleporter, now I was wondering how do I make it so that when this part is touched it will teleport the player (if they own premium) but instead of teleporting to another experience, I want it to teleport the player to a specific part I have in the same game?

The script:

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 = 012345678
 
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
		TeleportService:Teleport(placeID_Premium, player)
	-- 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)
1 Like

change this part to the teleport script
Like

Game.players.localplayer.character.primarypart.cframe = game.workspace.teleport2.cframe

When the answer below is exactly the same and you still mark it as solution :smiling_face_with_tear:

1 Like

Take a look at these lines here:

-- If the user already has Premium, teleport them to the Premium-only place
if player.MembershipType == Enum.MembershipType.Premium then
	TeleportService:Teleport(placeID_Premium, player)
-- Else, prompt Premium upgrade (use debounce to show it only once every few seconds)
else

The above snippet is from the upper middle of your script.

The line that says TeleportService:Teleport(placeID_Premium, player) is whats doing the teleportation in this script.

Instead of keeping whats currently there, you will want to delete that one line and replace it with something similar to the following:

local location = Vector3.new(0, 0, 0)
player.Character:SetPrimaryPartCFrame(CFrame.new(location))

In this case, you will want to change the location I’ve provided with the one you want the player to be teleported to.

3 Likes

Haha sorry, I appreciate both replies they helped me learn how to do it, so major thanks to both of you kind people! :saluting_face:

1 Like

I was just joking lol his is more in depth then mine about the solution.

1 Like

Sorry for asking again, I was just wondering, I tried the script in my game and it works perfectly except for one thing, I tried it on my alt, and when I touched the part it did show the purchase premium prompt but it still teleported the player even though they don’t have premium, do you have any idea how I can fix this?

By the lord ruler, you don’t need all that code!!!
Get marketplace service, check if they have premium, tp them, if they dont then prompt the purchase

1 Like

interesting, I would recommend doing simple code like Fused Honor suggests.

2 Likes

I believe I figured it out and it seems to be working fine, so I’ll put the code here in case someone wants to use this in the future (apologies if the code looks horrible lol, I’m not a good scripter)

Code:

local TeleportPart = script.Parent


local mps = game:GetService("MarketplaceService")


local isOpen = false


script.Parent.Touched:Connect(function(hit)

	local char = hit.Parent

	local plr = game.Players:GetPlayerFromCharacter(char)


	if not plr then return end


	if plr.MembershipType == Enum.MembershipType.Premium then

		if hit and hit.Parent and hit.Parent:FindFirstChild("HumanoidRootPart") then
			hit.Parent.HumanoidRootPart.Position = script.Parent.Parent.PremiumTP.Position
		end

	else

		mps:PromptPremiumPurchase(plr)

	end

end)
1 Like