Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does :LoadAsset returns nil?

Asked by
Bisoph 5
6 years ago
Edited 6 years ago

I'm trying to fix the Stamper tool from old Roblox. It should work as usual, but for some reason when I call :LoadAsset, it returns nil.

Can somebody please assist me? I want to make a building game.

Server script:

local InsertStuff = game:GetService('ReplicatedStorage').InsertStuff
local InsertService = game:GetService("InsertService")

InsertStuff.LoadAsset.OnServerInvoke = function(player, assetId)
    local asset = InsertService:LoadAsset(assetId)
    print(asset.Name)
    return asset
end

InsertStuff.LoadAssetVersion.OnServerInvoke = function(player, assetVersionId)
    return InsertService:LoadAssetVersion(assetVersionId)
end

Client script:

P.S. the client script has 3413 lines so i couldn't show all of it; I just showed the function where the problem lies.

    function StamperMain:LoadStampObject(stampObj,terrainShape)

        --[[WARNING, not using cacheing for terrain yet]]--
        if tonumber(stampObj.AssetId)==self.WaterAssetId then
            print('Loaded Water obj:'.. stampObj.AssetId)
            self.LastWaterObject = stampObj
            if not stampObj.Asset then
                stampObj.Asset = self.RbxStamper.GetStampModel(tonumber(stampObj.AssetId), terrainShape)
            end
            self:SetWaterProperties(stampObj.Asset,self.WaterGui:GetWaterData())
        elseif terrainShape and terrainShape>=0 then
            print('Loaded terrain obj:'.. stampObj.AssetId)
            stampObj.Asset = self.RbxStamper.GetStampModel(tonumber(stampObj.AssetId), terrainShape)
        elseif not stampObj.Asset then
            print('Loaded model obj:'.. stampObj.AssetId)
            stampObj.Asset = insertservicefolder:WaitForChild('LoadAsset'):InvokeServer( tonumber(stampObj.AssetId) ):GetChildren()[1] --where the problem is
            table.insert(self.ObjectCache, stampObj)
            if #self.ObjectCache > self.ObjectCacheSize then
                self.ObjectCache[1].Asset:Remove()
                --[[WARNING, Order n operation, replace with stack]]--
                table.remove(self.ObjectCache,1)
                print('removed object!')
            end
        end
    end
0
Line 19 it's Destroy not Remove User#19524 175 — 6y
0
i didn't write that code Bisoph 5 — 5y

Answer this question