Game pass place teleport

Does anyone have a fix for a script that teleports a person to a specific place when they touch a specific brick if they have a specific game pass? And if they don’t have the game pass, prompt them to buy it.
I had one that worked (I thought) but it breaks when someone goes through it.
My code:

local plr = game.Players.LocalPlayer

local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")


local mps = game:GetService("MarketplaceService")

local gamepassID = 0
local placeID = 0

local gamepassOwned = false

pcall(function()

	gamepassOwned = mps:UserOwnsGamePassAsync(plr.UserId, gamepassID)
end)



humanoid.Touched:Connect(function(touchedPart)
	if gamepassOwned == true then

	end


	if touchedPart == game.Workspace.TP then
		if gamepassOwned == true then
			game:GetService("TeleportService"):Teleport(placeID, game.Players.LocalPlayer)
		end
		mps:PromptGamePassPurchase(plr, gamepassID)
	end
end)


mps.PromptGamePassPurchaseFinished:Connect(function(playerPurchased, purchasedID, purchaseSuccess)

	if not purchaseSuccess then return end

	if playerPurchased == plr and purchasedID == gamepassID then


		gamepassOwned = true --where it might be going wrong

		game:GetService("TeleportService"):Teleport(placeID, game.Players.LocalPlayer)
	end
end)
2 Likes

Sure,
Touched Event For The Brick

To Prompt Gamepass

To Teleport The Player

And If you don’t know how to script you can hire someone here

1 Like

Ok but do you have any idea why this only works for the 1st person to use it?

local plr = game.Players.LocalPlayer

local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")


local mps = game:GetService("MarketplaceService")

local gamepassID = 0
local placeID = 0

local gamepassOwned = false

pcall(function()

	gamepassOwned = mps:UserOwnsGamePassAsync(plr.UserId, gamepassID)
end)



humanoid.Touched:Connect(function(touchedPart)
	if gamepassOwned == true then

	end


	if touchedPart == game.Workspace.TP then
		if gamepassOwned == true then
			game:GetService("TeleportService"):Teleport(placeID, game.Players.LocalPlayer)
		end
		mps:PromptGamePassPurchase(plr, gamepassID)
	end
end)


mps.PromptGamePassPurchaseFinished:Connect(function(playerPurchased, purchasedID, purchaseSuccess)

	if not purchaseSuccess then return end

	if playerPurchased == plr and purchasedID == gamepassID then


		gamepassOwned = true

		game:GetService("TeleportService"):Teleport(placeID, game.Players.LocalPlayer)
	end
end)
1 Like

It’s probably an error, check the output log.

I did, no errors. So I’ve got no idea why it is only working for one person.

Press f9 or type /console-

Try to make it tthat the script regens whenever someone goes through it?

Huh, that’s weird. I don’t see any errors in the code itself…

A way you might be able to do that is

humanoid.Touched:Connect(function(touchedPart)
	script:Clone() --clone into Parent
wait (0.1)
script:destroy() --destroy existing

	end

This is for scripting support, not a place to ask for scripts. Plus, you didn’t provide any code, nor any errors you have, so you have to include that in the OP

The script is right below the 1st comment.

That might not necessarily instantly be spoonfeeding or begging for scripts, I think that @ShadowAlien98 is just asking if anybody has a fix.

Did you see this + test it? It will regen the script, possibly getting around the 1 player issue.

^

We can’t help them with fixing if there’s no code provided to fix in the first place.

In the comments right below the whatever the topic thing is.

A fixed thread would be

Does anyone have a fix for a script that teleports a person to a specific place when they touch a specific brick if they have a specific game pass? And if they don’t have the game pass, prompt them to buy it.
I had one that worked (I thought) but it breaks when someone goes through it.
My code:

local plr = game.Players.LocalPlayer

local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")


local mps = game:GetService("MarketplaceService")

local gamepassID = 0
local placeID = 0

local gamepassOwned = false

pcall(function()

	gamepassOwned = mps:UserOwnsGamePassAsync(plr.UserId, gamepassID)
end)



humanoid.Touched:Connect(function(touchedPart)
	if gamepassOwned == true then

	end


	if touchedPart == game.Workspace.TP then
		if gamepassOwned == true then
			game:GetService("TeleportService"):Teleport(placeID, game.Players.LocalPlayer)
		end
		mps:PromptGamePassPurchase(plr, gamepassID)
	end
end)


mps.PromptGamePassPurchaseFinished:Connect(function(playerPurchased, purchasedID, purchaseSuccess)

	if not purchaseSuccess then return end

	if playerPurchased == plr and purchasedID == gamepassID then


		gamepassOwned = true --where it might be going wrong

		game:GetService("TeleportService"):Teleport(placeID, game.Players.LocalPlayer)
	end
end)

This is good. That would be a good edit to make @ShadowAlien98

I understand you added on your code later on but not including it in the OP gives me the right to assume that you are essentially asking for code. Category guidelines state to include code and your error

EDIT: Didn’t realize you did it already :grinning_face_with_smiling_eyes:

Just make sure to remove the

I added as just a little extra touch. :slight_smile:

@ShadowAlien98 Have you tried my idea?

humanoid.Touched:Connect(function(touchedPart)
	script:Clone() --clone into Parent
wait (0.1)
script:destroy() --destroy existing

	end

So what would the script be, with those changes.

Add it somewhere at the bottom.