Keep getting this errror : "ServerScriptService.2X Money Gamepass:14: attempt to call missing method 'SetAttribute' of table "

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I am trying to make all the attributes in parts to be multiplied by 2

  2. What is the issue? Include enough details if possible!
    it keeps giving me this error:
    "ServerScriptService.2X Money Gamepass:14: attempt to call missing method ‘SetAttribute’ of table "

  3. What solutions have you thought of so far?
    I havent

Script:

local marketplaceService = game:GetService("MarketplaceService")
local players = game:GetService("Players")

local gamePassId = 987299127

local function GivePerk(player)
	local character = player.Character or player.CharacterAdded:Wait()
	if character ~= nil then
		local humanoid = character:FindFirstChild("Humanoid")
		if humanoid ~= nil  then
			local serverStorage = game:GetService("ServerStorage")
			local dropsFolder = serverStorage:WaitForChild("Drops")
			local drops = dropsFolder:GetChildren()
			drops:SetAttribute("Worth", 2)
			
		
			
			
			
			
		end
	end
end



local function PlayerAdded(player)
	local hasPass = false
	
	local success, errorMsg = pcall(function()
		hasPass = marketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassId)
	end)
	
	if not success then 
		warn(errorMsg)
		return
	end
	
	
	if hasPass then
		GivePerk(player)
	end
end
local function onPromptPurchaseFinished(player, purchasedGamepassId, purchaseSuccess)
	if purchaseSuccess and purchasedGamepassId == gamePassId then
		print(player.Name.. "Bought this gamepass")
		GivePerk(player)
	end
end


players.PlayerAdded:Connect(PlayerAdded)
marketplaceService.PromptGamePassPurchaseFinished:Connect(onPromptPurchaseFinished)

It’s self-explanatory. You’re trying to change attributes of a table, the function only works on Instances.

for _, Drop in pairs(drops) do
	Drop:SetAttribute("Worth", 2)
end
2 Likes

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