How do i made a weight inventory system?

It feels like whole script doesnt run

I tried it like I said.
image
Can you give me a rbxl with only the tools?

Im having test place with few stuff im working on. Its kinda messy. You could look at screenshots from one of my replies.
I have nothing in output when starting test or picking items.

local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
	local MaxWeight = Instance.new("IntValue")
	MaxWeight.Name = "MaxWeight"
	MaxWeight.Value = 25
	MaxWeight.Parent = Player
	local Weight = Instance.new("IntValue")
	Weight.Name = "Weight"
	Weight.Value = 0
	Weight.Parent = Player
	Player.CharacterAdded:Connect(function(Character)
		local Backpack = Player.Backpack
		Backpack.ChildAdded:Connect(function(Child)
			if Child:IsA("Tool") then
				Player.Weight.Value += Child:GetAttribute("Weight")
			end
		end)
		Backpack.ChildRemoved:Connect(function(Child)
			if Child:IsA("Tool") then
				if Character:FindFirstChild(Child.Name) then -- Player just equipped it.
					return
				end
				Player.Weight.Value -= Child:GetAttribute("Weight")
			end
		end)
	end)
end)
function CloneItemAndGivetoPlayer(Player:Player?, Tool:Tool?)
	if Player.Weight.Value ~= Player.MaxWeight.Value then -- Maximum weight threshold not reached yet.
		Tool:Clone().Parent = Player.Backpack
	else
		warn("Maximum weight! Cannot give anymore tools!")
	end
end
--Example cloning
local Prom:ProximityPrompt? = workspace.ProximityPrompt.ProximityPrompt
Prom.TriggerEnded:Connect(function(Player)
	if Player.Character and Player.Character:FindFirstChildOfClass("Humanoid").Health > 0 then
		CloneItemAndGivetoPlayer(Player, game:GetService("ServerStorage").Tools.Sword)
	end
end)

Try using this and MAKE sure all OF YOUR TOOLS have a number attribute named Weight.
image
After you’re done picking up your tools, try triggering the proximity prompt!

2 Likes

OH, im sorry, instead of making part to set position of proximity prompt, and then use proximity prompt, i placed tools in workspace, and i was thinking that proximity prompt will appear on each tool called “Tool” and move to inventory. It works now

Alright, you can mark my solution as “solution” so this thread gets closed.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.