Set a value to a tool in the players backpack

So basically, i want to set a value inside the player to be the tool that the player currently has in their backpack. how could i make this?

It is, i’ve just made it. i just didnt see the simple solution. thanks anyway.

Although you found your solution for those who weren’t aware the correct approach would be to make use of an “ObjectValue” instance and assign to its “Value” property the tool instance itself whenever it is equipped by the player’s character. Here’s an example script.

local players = game:GetService("Players")

local function onPlayerAdded(player)
	local function onCharacterAdded(character)
		local function onToolEquipped(tool)
			if tool:IsA("Tool") then
				player.Tool.Value = tool
			end
		end
		character.ChildAdded:Connect(onToolEquipped)
	end
	player.CharacterAdded:Connect(onCharacterAdded)
	
	local equippedTool = Instance.new("ObjectValue")
	equippedTool.Name = "Tool"
	equippedTool.Parent = player
end

players.PlayerAdded:Connect(onPlayerAdded)
1 Like