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

Why does it say index nil with ' userId?

local id = whatever gampass id local market = game:GetService('MarketplaceService') local owner = game.Workspace.TYCOONS.FirstTycoon.TycoonInfo.Owner

game.Workspace.TYCOONS.FirstTycoon.Buttons.Robux.Button.Touched:Connect(function(Hit,player) if Hit and Hit.Parent:FindFirstChild("Humanoid") then local players = game.Players:GetPlayerFromCharacter(Hit.Parent) if players and owner.Value == players then if market:UserOwnsGamePassAsync(player.userId, id) and game.Workspace.TYCOONS.FirstTycoon.Essentials.Conveyor.Value.Value == false then game.Workspace.TYCOONS.FirstTycoon.Essentials.Conveyor.Value.Value = true end end end end)

it says index nill with userId why

1 answer

✓ Accepted answer

I had some difficulties to understand your Script, but I think I found a solution, I haven't tested it yet, but I think it should work.

local Market = game:GetService("MarketplaceService")
local Button = Workspace.TYCOONS.FirstTycoon.Buttons.Robux.Button
local Id = -- GamePass Id

local ECValue = Workspace.TYCOONS.FirstTycoon.Essentials.Conveyor.Value

Button.Touched:Connect(function(Hit)
	if Hit.Parent:FindFirstChild("Humanoid") then
		local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
		if Player and owner.Value == Player.Name then
			if market:UserOwnsGamePassAsync(Player.UserId, id) then
				if ECValue.Value == false then
					ECValue.Value = true
				end
			end
		end
	end
end)

You confused the variables, Players and Player, changing their values, so the Script returned UserId = Nil, because Player, was the same as the Players Service, while Players, was the player itself.

Try this... If it doesn't work, I need you to point out the error so I can know how to fix it more easily.

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