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)
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)
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)
This discussion is preserved as it was. New answers, comments, and votes are closed.
14 comments
that doesnt work
any errors?
If it’s a GP then change line 6 to “UserOwnsGamePassAsync(plr,Id)” after MPS
18:51:10.450 - Argument 2 missing or nil
line 06?
did you declare the Id variable?
I opened up studio and tested the code it works just fine, as ABK said if its a gamepass change it to UserOwnsGamePassAsync
did it but still same ;-;
its a pass
Change PlayerOwnsAsset(plr,Id) to UserOwnsGamePassAsync(plr.UserId,Id)
i did
did you put plr.UserId in the parameter?
UserOwnsGamePassAsync(plr.UserId,Id) needs the userid of the player not the player instance
i did that all but still wont work ;-;