I can't find whats wrong with my code! I am getting an error, but dont know what it means
1 | local Id = 5266510 |
2 | script.Parent.Touched:Connect( function (hit) |
3 | game:GetService( "MarketplaceService" ):PlayerOwnsAsset(Id) |
4 | script.Parent.CanCollide = false |
5 | 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
01 | local Id = 5266510 |
02 | script.Parent.Touched:Connect( function (hit) |
03 |
04 | if hit.Parent:FindFirstChild( "Humanoid" ) then --make sure the object touching the door is a player |
05 | local plr = game.Players:GetPlayerFromCharacter(hit.Parent) |
06 | if game:GetService( "MarketplaceService" ):PlayerOwnsAsset(plr,Id) then |
07 | script.Parent.CanCollide = false |
08 | end |
09 | end |
10 | end ) |