It would be cool if this compressed the inventory data; if it doesn’t that-
Now that I think about it I can make a inventory handler Module or something (for my “framework”) which allows for stuff like that, well hope everything is good;
BTW to anyone using this: the viewportframe script can be really laggy, depending on your device, you may want to disable it, or if you’re good at that kinda stuff, reduce the lag…somehow…
--Plr wants to drop an item
senddrop.OnServerEvent:Connect(function(player,itemname)
if game.ServerStorage.Inventory[player.Name]:FindFirstChild(itemname) then
local item = game.ServerStorage.Inventory:FindFirstChild(player.Name)[itemname]
if item.Amount.Value == itemsmodule[itemname]["Amount"] then
item.Amount.Value = item.Amount.Value - itemsmodule[itemname]["Amount"]
item:Destroy()
else
item.Amount.Value = item.Amount.Value - itemsmodule[item.Name]["Amount"]
end
game.ServerStorage.Inventory:FindFirstChild(player.Name).Weight.Value = game.ServerStorage.Inventory:FindFirstChild(player.Name).Weight.Value - itemsmodule[itemname]["Weight"]
print(game.ServerStorage.Inventory:FindFirstChild(player.Name).Weight.Value)
local newitem = game.ServerStorage.Items:FindFirstChild(itemname):Clone()
newitem.Parent = game.Workspace.Items
newitem.PrimaryPart.Position = game.Workspace[player.Name].HumanoidRootPart.Position
UpdateInventoryUI(player)
end
end)
And put on each model the corresponding primarypart of that model.
And add a weld to all parts of the model to the main one.
Everything seems to work but I made my own Sword and it can equip and stuffs but the problem is dropping it… It shows me this error PrimaryPart is not a valid member of Tool “Workspace.Items.Greatsword” What does this mean how do I fix it?
Differentiate between parts/model and tools when dropping an object. Because in tools you can’t get the PrimaryRootPart nor its location (only with its Handler member).
And use better :PivotTO(), because PrimaryRootPart is becoming obsolete.
Hippity Hoppity your code is now my property. Thank you so much for open sourcing this, this will help lots of games! I will be sure to credit you if I use this.