Why won't my script work?

I’m trying to make VIP exclusive foods for my game, so I made this script:

commands.giveto = function(sender,arguments)
	if sender:GetRankInGroup(11635716) >= 3 then
		local character = sender.Character or sender.CharacterAdded:Wait()
		local item
		for i, tool in pairs(character:GetChildren()) do
			if tool.ClassName == "Tool" and tool.Name ~= "Mop" and tool.Name ~= "Notepad" then
				item = tool
				print(item.Name) break
			end
		end
		
		if not item then return end

		for i, playerName in pairs(arguments) do
			print(playerName)
		end
		local customerName = arguments[1]

		if customerName then
			local customer = findPlayer(customerName)
			if customer then
				print(item.Name)
				if item.Name == ("Atole" or "CoffeeMilk" or "Hwachae" or "Licuado" or "Sujeonggwa" or "YujaCha" or "Consomme" or "Crostini" or "Sushi" or "DimSum" or "Dondurma" or "Pavlova")then
					local hasPass = false
					local success, message = pcall(function()
						hasPass = MarketplaceService:UserOwnsGamePassAsync(customer.UserId, 95142223)
					end)
					if not success then
						print("Error checking VIP pass:"..tostring(message))
					end
					print(hasPass)
					if hasPass then
						item.Parent = customer:WaitForChild("Backpack")
						addPoints.addPoints(sender, 1)
					else
						MarketplaceService:PromptGamePassPurchase(customer, 95142223)
					end
				else
					item.Parent = customer:WaitForChild("Backpack")
					addPoints.addPoints(sender, 1)
				end
			end
		end
	end
end

What it does, is it checks if when you are trying to hand a food to someone, if that food is VIP exclusive. Then it checks if the customer is VIP. If they aren’t, it prompts them to buy the pass. If they are, it gives them the food. I tested this though, and it won’t work if the customer isn’t VIP. Why is this happening?

1 Like

What does if sender:GetRankInGroup(11635716) >= 3 then mean?

They have to be whatever that is before the script will run.

1 Like

I don’t think that’s the problem… The customer is a whole different player than the sender.

1 Like

This won’t work similarly to English; Luau will only check the first value (since it’ll try to evalute the strings as truthy values).

You’d want to insert the item names into a list and check the list:

if table.find({ --[[Enter item names here]] }, item.Name) then
3 Likes

That’s just making sure the person with the item is high enough rank to hand it to someone else.

Can you be more spceific about what is not working.

The entire script or a specific part of it.

It’s everything after the if item.Name ==
I think @HugeCoolboy2007 might have fixed it. I’ll have to see later.

Does it give out an error output?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.