Gamepass Script Error

So, I was making a gamepass, that if you touch this little thing, then it allows you to be teleported to another game. But it always comes up with this error.
image

This is my script:

local id = 23108485
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local teleportPart = script.Parent
local targetPlaceID = 7606460453  -- Change this to your place ID

-- Require teleport module
local TeleportModule = require(ReplicatedStorage:WaitForChild("TeleportModule"))

script.Parent.Touched:Connect(function(Player, hit)
	if game:GetService("GamePassService"):PlayerHasPass(Player, id) then 
		local player = Players:GetPlayerFromCharacter(hit.Parent)

		if player and not player:GetAttribute("Teleporting") then
			player:SetAttribute("Teleporting", true)

			-- Teleport the player
			local teleportResult = TeleportModule.teleportWithRetry(targetPlaceID, {player})

			player:SetAttribute("Teleporting", nil)
		end
	else
		print(Player.Name .. " doesn't have the game pass...")
	end
	end)










can you send a screenshot of the error? It would say the line that has the error

try
(targetPlaceID, player)
{} means table

It doesn’t work, it says the error is on line 12.

your using

but i use MarketplaceService
UserOwnsGamePassAsync

Hm, okeh, How would I modify my script to put that in. Could you point me in the right direction?

local id = 23108485
--when a player joins the game
game.Players.PlayerAdded:Connect(function()
    --  MarketplaceService =  mps
    local mps = game:GetService('MarketplaceService ')
    -- print if the player has the pass
    print(mps:UserOwnsGamePassAsync(player.UserId,id))
end)

did not use roblox studio

you got 2 arguments at .Touched event… .Touched event only has 1 argument. and thats called “hit” which is gets the part that touched…
u need to get the player first to check if player has gamepass…

Did I implement it correctly?
Because its giving me this error:


Here is the new script.

local id = 23108485
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local teleportPart = script.Parent
local targetPlaceID = 7606460453  -- Change this to your place ID
local mps = game:GetService("MarketplaceService")
-- Require teleport module
local TeleportModule = require(ReplicatedStorage:WaitForChild("TeleportModule"))

script.Parent.Touched:Connect(function(hit)
	local player = Players:GetPlayerFromCharacter(hit.Parent)
	if 	mps:UserOwnsGamePassAsync(player.UserId,id) then 
	

		if player and not player:GetAttribute("Teleporting") then
			player:SetAttribute("Teleporting", true)

			-- Teleport the player
			local teleportResult = TeleportModule.teleportWithRetry(targetPlaceID, {player})

			player:SetAttribute("Teleporting", nil)
		end
	else
		print(player.Name .. " doesn't have the game pass...")
	end
	end)

--when a player joins the game










Touched doesn’t provide the player instance, it only gives the hit variable. First check for a humanoid to see if it’s a character, then check if you can get a player, like you did above, like this

if hit.Parent:FindFirstChild("Humanoid") then
   if game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) then
     local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
            --Prompt gamepass, because we know it's the player.
   end
end

you see where i typed :here:
type player and there
hope your not cofused

Here’s the new script.

local id = 23108485
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local teleportPart = script.Parent
local targetPlaceID = 7606460453  -- Change this to your place ID
local mps = game:GetService("MarketplaceService")
-- Require teleport module
local TeleportModule = require(ReplicatedStorage:WaitForChild("TeleportModule"))

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("RightArm") then
	local player = Players:GetPlayerFromCharacter(hit.Parent)
	if 	player and mps:UserOwnsGamePassAsync(player.UserId,id) then 
	

		if player and not player:GetAttribute("Teleporting") then
			player:SetAttribute("Teleporting", true)

			-- Teleport the player
			local teleportResult = TeleportModule.teleportWithRetry(targetPlaceID, {player})

			player:SetAttribute("Teleporting", nil)
		end
	else
		print(player.Name .. " doesn't have the game pass...")
		end
	else
		print("MAN NOT")
		end
	end)

--when a player joins the game










It’s giving the argument error again, what did I do wrong?
Here’s the new script:

local id = 23108485
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local teleportPart = script.Parent
local targetPlaceID = 7606460453  -- Change this to your place ID
local mps = game:GetService("MarketplaceService")
-- Require teleport module
local TeleportModule = require(ReplicatedStorage:WaitForChild("TeleportModule"))

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Right Arm") then
	local player = Players:GetPlayerFromCharacter(hit.Parent)
	if 	player and mps:UserOwnsGamePassAsync(player.UserId,id) then 
	

		if player and not player:GetAttribute("Teleporting") then
			player:SetAttribute("Teleporting", true)

			-- Teleport the player
			local teleportResult = TeleportModule.teleportWithRetry(targetPlaceID, {player})

			player:SetAttribute("Teleporting", nil)
		end
	else
		print(player.Name .. " doesn't have the game pass...")
		end
	else
		print("MAN NOT")
		end
	end)

--when a player joins the game










I don’t feel like going on Discord at the moment, sorry.