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

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

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?

1 comment

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.

2 answers

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!

1 comment

0

Error: 23:17:07.263 - Players.MinecraftButterfly87.PlayerGui.StaffDoorScript:23: attempt to index nil with 'PlayerHasPass'

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

4 comments

0

Error: 23:17:07.263 - Players.MinecraftButterfly87.PlayerGui.StaffDoorScript:23: attempt to index nil with 'PlayerHasPass'

0

Can you please show the rest of your script?

0

That's my whole script.

0

The error is on line 23. There's no line 23 on your script so it's the wrong script.

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