Unable to cast value to object on line 09.
Trying to make a gamepass door sort of thing so when you walk "through" the door, the game prompts a gamepass purchase of the gamepass i set in the script.gamepassid.value value, and then it will check to see if you own it and if you do then it will teleport you to the other side. if someone could help me with this then that would be awesome :D thanks
local hasgamepass = false
local function OnTouched(otherPart)
if otherPart and otherPart.Parent and otherPart.Parent:FindFirstChild('Humanoid') then
local player = PlayersService:GetPlayerFromCharacter(otherPart.Parent)
if player and not JustTouched[player] then
JustTouched[player] = time()
end
if hasgamepass == false then
GamePassService:PromptGamePassPurchase(player.userId, script.GamePassId.Value)
end
if GamePassService:UserOwnsGamePassAsync(player.userId, script.GamePassId.Value) then
TeleportToOtherSide(player.Character, otherPart)
local hasgamepass = true
end
end
end

1 comment
Your problem is the first argument you passed "player.userId," is a number. You want a player object. Replace it with just player. https://wiki.roblox.com/index.php?title=API:Class/MarketplaceService