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

PlayerOwnsAsset problem, arugment missing or nil. How do I fix it?

I have a issue with PlayerOwnsAsset. They "if game:GetService" line says Arugment Missing or Nil.

plr = game.Players:FindFirstChild(script.Parent.Parent.Parent.Selecteduser.User.Text)
passId = 1761589018

script.Parent.MouseButton1Click:Connect(function()
	if game:GetService("MarketplaceService"):PlayerOwnsAsset(plr, passId) then
		script.Parent.Parent.Parent.Parent.BusinessAgree:TweenPosition(UDim2.new(.042,0,.352,0))
		script.Parent.Parent.Parent.Parent.BusinessAgree["Check-in"].TextLabel.Text = "The following player has Business, please press continue."
	else
		script.Parent.Parent.Parent.Parent.BusinessAgree:TweenPosition(UDim2.new(.042,0,.352,0))
		script.Parent.Parent.Parent.Parent.BusinessAgree["Check-in"].TextLabel.Text = "The following player does not have Business, this will automatically close now"
	end
end)

2 comments

0

is you're gamepass a legacy game pass? if so, use GamePassService

0

Its a tshirt.

1 answer

✓ Accepted answer

The reason why it's erroring with Argument Missing or Nil is because you're defining the player wrong, and is not a safe way to define the player at all. Assuming this is a LocalScript, you would instead need to use game.Players.LocalPlayer.

Also, another thing that's wrong with your script is the HUGE amounts of script.Parent's, it's very unnecessary in my opinion and reduces readability by a lot, which is something programmers should generally keep in mind when making scripts. Assuming the code you're showing right now is the only code in your script, you can just move the LocalScript closer to the MainFrame or whatever is close to BusinessAgree to avoid the script.Parent.Parent, etc, or you can just use variables.

Lastly, use never forget to make your variables local.

So you could do this instead

local plr = game.Players.LocalPlayer
local passID = 1761589018
local button = button location --was script.Parent
local BusinessAgree = location

button.MouseButton1Click:Connect(function()
	if game:GetService("MarketplaceService"):PlayerOwnsAsset(plr, passId) then
		--code
	else
		--code
	end
end)

3 comments

0

I didn't even notice this was a local script lel

0

We fixed it via discord!

0

GuiObjects should generally be eddited on the client, so that's how I assumed it was a LocalScript

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