Is possible to reward a tool to a player that own a specify ugc?
You can use MarketplaceService::PlayerOwnsAsset to see if a player owns the UGC item based, and from there you can place a tool in the player’s backpack.
local UGC_ITEM_ASSET_ID = "rbxassetid://123456789"
local TOOL_NAME = "MyTool" -- Name of tool
local MarketplaceService = game:GetService("MarketplaceService")
local ServerStorage = game:GetService("ServerStorage")
local Players = game:GetService("Players")
local function onPlayerAdded(player: Player)
if MarketplaceService:PlayerOwnsAsset(player, UGC_ITEM_ASSET_ID) then
local tool = ServerStorage:WaitFirstChild(TOOL_NAME):Clone()
tool.Parent = player:WaitForChild("Backpack")
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
for _, player in Players:GetPlayers() do
onPlayerAdded(player)
end
2 Likes
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.