You can write your topic however you want, but you need to answer these questions:
-
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 -
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 " -
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)