Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why will my door not set CanCollide to false and what is this error?

Asked by 4 years ago

The error:

  23:05:46.807 - Players.MinecraftButterfly87.PlayerGui.StaffDoorScript:23: attempt to index nil with 'PlayerHasPass'

The LocalScript inside StarterGui:

game.Players.PlayerAdded:Connect(function(player)
    if game.MarketplaceService:PlayerOwnsAsset(player,9304750) then
        game.Workspace.Backdrop.Obby.VIP.CanCollide = false
    end
end)

What should I do to fix this error and make the door's CanCollide property be false for players who own the VIP gamepass?

0
That PlayerHasPass error isn't in the script you posted. I believe that error is from another script. If it's not, then please post that script too. Tyler090130 619 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

You should be using UserOwnsGamePassAsync() when using game passes. Here try this:

game.Players.PlayerAdded:Connect(function(player)
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 9304750) then
        workspace.Backdrop.Obby.VIP.CanCollide = false
    end
end)

Read about UserOwnsGamePassAsync() here. If this helped, be sure to accept this answer!

0
Error: 23:17:07.263 - Players.MinecraftButterfly87.PlayerGui.StaffDoorScript:23: attempt to index nil with 'PlayerHasPass' MinecraftButterfly87 10 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

You're supposed to use :UserOwnsGamePassAsync. Also, don't use the PlayerAdded event since LocalScripts are automatically parented to every player when they are added. Try this:

repeat wait() until game:GetService("Players").Character

if game:GetService("MarketplaceService"):UserOwnsGamePassAsync (game:GetService("Players").LocalPlayer.UserId, 9304750) then
    game.Workspace.Backdrop.Obby.VIP.CanCollide = false
end
0
Error: 23:17:07.263 - Players.MinecraftButterfly87.PlayerGui.StaffDoorScript:23: attempt to index nil with 'PlayerHasPass' MinecraftButterfly87 10 — 4y
0
Can you please show the rest of your script? youtubemasterWOW 2741 — 4y
0
That's my whole script. MinecraftButterfly87 10 — 4y
0
The error is on line 23. There's no line 23 on your script so it's the wrong script. youtubemasterWOW 2741 — 4y

Answer this question