Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

hi i need help idk what is wrong with this script? it saysGamepassId is not a valid member

Asked by 5 years ago

whats wrong with this script

local debounce = false 

script.Parent.Touched:connect(function(hit)
    if debounce == false then 
        wait()
        debounce = true 
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        local GamePassId = script.Parent.GamepassId
        local marketplaceservice = game:GetService("MarketplaceService")
        if player and marketplaceservice:PlayerOwnsAsset(player, gamepassId.Value) then
            script.Parent.CanCollide = false
            wait(.5) 
            script.Parent.CanCollide = true
        end
    end
    wait(2)
    debounce = false 
end)

it says GamepassId is not a valid member of Part

0
I'm going to assume that this is a Script, and according to my testing, it will error if you capitalize wrong (game.Workspace.name will error, game.Workspace.Name will not). My suggestion is for you to make sure that all references of GamepassId in your code is typed exactly the same, as I think it's case sensitive. KicksForTricks56 36 — 5y

2 answers

Log in to vote
0
Answered by
zblox164 531 Moderation Voter
5 years ago
Edited 5 years ago

Gamepassesare no longer assets they are their own class. You should not use PlayerOwnsAsset()and switch it out with UserOwnsGamePassAsync().

How you would use it in your script:

local debounce = false 

script.Parent.Touched:connect(function(hit)
    if debounce == false then 

        wait()

        debounce = true 

        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        local GamePassId = script.Parent.GamepassId
        local marketplaceservice = game:GetService("MarketplaceService")

        if player and marketplaceservice:UserOwnsGamePassAsync(player, gamepassId.Value) then
            script.Parent.CanCollide = false

            wait(.5) 

            script.Parent.CanCollide = true
        end
    end

    wait(2)

    debounce = false 
end)

The script is untested but should work. Hope this helps!

0
didnt work... ihatehackers321123 9 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Case sensitivity is really important in lua, so if you accidentally use Part:DEstroy() instead of Part:Destroy(), it matters by a lot. Since :DEstroy doesn't exist, it will error something like, "DEstroy" is not a valid member of Part. I'll fix some errors you did on your script.

Line 10

if player and marketplaceservice:PlayerOwnsAsset(player, gamepassId.Value) then

should be

if player and marketplaceservice:PlayerOwnsAsset(player, GamePassId.Value) then

just like in Line 8 where it said:

local GamePassId = script.Parent.GamepassId

I hope this helps you.

Answer this question