Edit: I’ve posted the working version of this script for anyone who made need to use something similar in the future!
I’m working on adding functionality to my game so that when users purchase a specific item in the group store they are awarded with various tools for having purchased it. The script I have now is functional, but I feel like it’s very inefficient, especially for dealing with multiple assets (four t-shirts) that are each awarding different gear (i.e. owning t-shirt #1 might get you tool #1, but owning t-shirt #2 might get you tool #1 and tool #2). If you can, please help show me a more efficient way of going about this/let me know what improvements and changes I can make.
local Tool1 = "toolname" local Asset1 = 123456789 local MarketplaceService = game:GetService("MarketplaceService") local ServerStorage = game.GetService("ServerStorage") game.Players.PlayerAdded:connect(function(Player) local StarterGear = Player:WaitForChild("StarterGear") if MarketplaceService:PlayerOwnsAsset(Asset1) then if ServerStorage.Tools.FindFirstChild(Tool1) then ServerStorage.Tools.FindFirstChild(Tool1):Clone().Parent = StarterGear end end end)