Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why wont my vip door work? I have tried multiple times!

I can't find whats wrong with my code! I am getting an error, but dont know what it means

local Id =  5266510
script.Parent.Touched:Connect(function(hit)
game:GetService("MarketplaceService"):PlayerOwnsAsset(Id)
script.Parent.CanCollide = false
end)

1 answer

You didnt put the player instance in the PlayerOwnsAsset method, and the method returns a bool value so you should use an if else statement

local Id =  5266510
script.Parent.Touched:Connect(function(hit)

  if hit.Parent:FindFirstChild("Humanoid") then--make sure the object touching the door is a player
     local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
     if game:GetService("MarketplaceService"):PlayerOwnsAsset(plr,Id) then
        script.Parent.CanCollide = false
     end
  end
end)

14 comments

0

that doesnt work

0

any errors?

1

If it’s a GP then change line 6 to “UserOwnsGamePassAsync(plr,Id)” after MPS

0

18:51:10.450 - Argument 2 missing or nil

0

line 06?

0

did you declare the Id variable?

1

I opened up studio and tested the code it works just fine, as ABK said if its a gamepass change it to UserOwnsGamePassAsync

0

did it but still same ;-;

0

its a pass

0

Change PlayerOwnsAsset(plr,Id) to UserOwnsGamePassAsync(plr.UserId,Id)

0

i did

0

did you put plr.UserId in the parameter?

0

UserOwnsGamePassAsync(plr.UserId,Id) needs the userid of the player not the player instance

0

i did that all but still wont work ;-;

This discussion is preserved as it was. New answers, comments, and votes are closed.