How would I make a Gamepass Teleporter?

Hi there! I’m not going to introduce myself and get straight to the point. Basically, I want to make a Gamepass teleporter, so if you own a gamepass and touch the teleporter brick, you get teleported. Now matter what I try it never works, whether it be free models or tutorials. Could anyone help me with this?

Additional information:
I have my two teleporters in one model.
The gamepass ID is 11173507 (And I own it).
If you need any more info, please ask.

Thanks, trophy <3

1 Like

Few steps u should follow:

  1. Everything should be server sided
  2. teleporter.Touched event for listening for touch
  3. Checking if a player owns the gamepass, hit.Parent, :PlayerHasPass()
  4. Setting player’s HumanoidRootPart.CFrame, for teleport

I see, thank you :). I believe PlayerHasPass() is deprecated now though, what should I use?

Maybe try using UserOwnsGamePassAsync.

game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, GamepassID)

Thank you. I have been testing and nothing is working yet again, this is what I put in a local script inside of the teleporter brick. I am not attempting teleporting just yet just so I can make sure the script does work.

local player = game.Players.LocalPlayer

script.Parent.Touched:Connect(function()
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 11173507) then
		print("Owns Gamepass!")
	end
end)

Is the teleporter inside of workspace? Btw local scripts cant be run in workspace, they just dont work

You need to make a script, as you want it to be server-sided, and it won’t function as you desire with the localscript. So what I’m stating is, you’d need to use a script rather than a localscript.

Alright, so I put the code in a script:

local player = game.Players.LocalPlayer

script.Parent.Touched:Connect(function()
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 11173507) then
		print("Owns Gamepass!")
	end
end)

and got this error:
Workspace.Teleports.tele1.Script:4: attempt to index nil with ‘UserId’
I’m not sure what happened here?

On short u should move the code into server script:

script.Parent.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") then
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(hit.Parent.UserId, 11173507) then
		print("Owns Gamepass!")
     end	
    end
end)

I am on phone so sorry for weird formation

You can’t use game.Players.LocalPlayer in scripts, only in localscripts. If you’re configuring a script and want to manage the player, you’d use game.Players.PlayerAdded:Connect(function(plr). Since you’re making a touch brick, I’d recommend using @nuttela_for1me’s code, as you’d only get that player from the character that hit the object.

Oh yes I missed that, u need to actually use :GetPlayerFromCharacter(hit.Parent) to get the player

1 Like

Ok sweet, it works! Thanks so much! I’m trying the teleport script now. Thank you both so much for the help <3

I’m a good builder but not so experienced with scripting so I appreciate it :smile:

1 Like

Awesome! Managed to figure it out, thanks so much for the help <3

I love the devforum so much, everyone is so kind and smart and help a lot, I appreciate this so much because my dumb self wouldve taken a week to figure this out hahah

2 Likes

Try this:

local Gamepass = 11173507
local Place = 00000 -- Place ID

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(hit.Parent.UserId, Gamepass) then
            print("Owns Gamepass!")
            game:GetService("TeleportService"):Teleport(Place, hit.Parent)
        end	
    end
end)