Hey there, I wanted to make a GUI that changes the part’s color if you have a gamepass. But the script doesn’t work. It says “attempt to index nil with ‘UserId’”. I don’t understand why this script doesn’t work, since if I put my own UserId rather than “player.UserId” it works completely fine.
I tried changing the script based on Devforum posts and Youtube tutorials but none of it worked.
If you could help me out, I would really appreciate it.
Here’s is the script:
local player = game.Players.LocalPlayer
local gamepassId = 92766320
script.Parent.Frame.DarkRed.MouseButton1Click:Connect(function()
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,gamepassId) == true then
game.Workspace.Color.Part1.BrickColor = BrickColor.new("Crimson")
else
print("failed")
end
end)