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
Gamepasses
are 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!
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.