I want a brick that can be walked through if someone has a gamepass and it doesn't work, here's my script (it's a local script)
01 | local PassId = 4835177 |
02 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
03 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
04 | local getPlayerFromCharacter |
05 | local player |
06 |
07 |
08 | script.Parent.Touched:Connect( function (hit) |
09 | player = getPlayerFromCharacter(hit.Parent) |
10 | if MarketplaceService:UserOwnsGamePassAsync(player.UserId, PassId) then |
11 | script.Parent.CanCollide = false |
12 | end |
13 | end ) |
You might need a Script instead of a LocalScript.
A Script can work on almost everything and can run most functions excluding functions only for LocalScripts and CoreScripts. Accoreing to Roblox Wiki, a LocalScript will work only on selected areas:
A Player's Backpack, such as a child of a Tool A Player's Character model A Player's PlayerGui A Player's PlayerScripts The ReplicatedFirst service
You probably placed your script inside a Part and it will not function at all.