I'm trying to make a script that adds an accessory to your character when a remote event is triggered. I've tried handling it all in a local script but you cant load assets in a local script. Any ideas?
Edit: I fixed it, all I had to do was add :GetChildren()[1] to the end of Line 9 of the server Script
Local Script:
local btn = script.Parent local RS = game:GetService('ReplicatedStorage') local event = RS:WaitForChild('CustomizationEvent') local IService = game:GetService('InsertService') local player = game.Players.LocalPlayer btn.MouseButton1Down:Connect(function() local AssetID = tonumber(btn.Parent.AssetIDInput.Text) local success = pcall(function() game:GetService('MarketplaceService'):GetProductInfo(AssetID) end) if not success then warn('Asset number'..AssetID..'not an asset') end event:FireServer(AssetID) end)
Script:
-- Customization Variable(s) local CustomizationEvent = RS:WaitForChild('CustomizationEvent') local IService = game:GetService('InsertService') CustomizationEvent.OnServerEvent:Connect(function(player, AssetID) local asset = IService:LoadAsset(AssetID) if not asset:IsA('Accessory') then asset:Destroy() return end asset.Parent = player.Character end)