I'd like to know a lot more about how tools work

This method is working much better than the one I was working on, so thanks :grin:

Working on a different system now that’s able to cycle through the tools like in the default backpack but using this method instead

This is the script I’m using to detect if it’s working when I click, it’s not printing anything.

local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
script.Parent.Activated:Connect(function(player)
	mouse.Button1Down:Connect(function()
		print "Activated"
	end)
end)

This is what I’m using to equip the tool to the player, is anything from these incorrect?

for i, current in ipairs(toolFolder:GetChildren()) do
				if current.Name == object.Name then
					toolvalue.Value = true
					newtool = current:Clone()
					newtool.Parent = player.Character
					task.wait()
					player.Character.Humanoid:EquipTool(newtool)
				end
			end

That’s a memory leak, activated on its own should already detect when a player clicks their mouse

1 Like

Not concerned about that as this was just a test, but it’s not working and I have no clue why. Can you tell why?

I’m starting to suspect the issue might be happening because of something else since I’m unable to replicate this behavior when I test it myself, how are your Tool’s properties configured?

I tried testing this in a new baseplate and was unable to replicate the issue, this is the place file of this test: ToolExample.rbxl (55.2 KB)

Is there anything else that could be causing this issue? Like character being locked to first person or literally anything like that you can think of?

Wait I believe I MAY have discovered the issue, it’s because my grab script. I tested it again by just putting the tool into workspace and walking over it with the grab script disabled. I think it may be because whenever I click it is trying to instead grab the tool? I’m not entirely sure but I’ll look into it

1 Like

If your grab script uses ClickDetectors you can disable them while the Tool is equipped by setting the MaxActivationDistance to 0 or nil, then re-enable them again when the Tool is dropped

1 Like

It unfortunately enough for me, is not using click detectors. There is no easy way out of this for me, I will probably have to rewrite huge chunks of code >:(

1 Like

The good news here is I actually just thought of a really clever way of dealing with this issue that won’t make me have to rewrite huge chunks of code, I can just disable the script entirely whenever the player is holding an object. (Since my grab script has nothing to do with my inventory script other than sending the server information it needs to store items.)

(This is because I made the entire script out of functions btw, so I can choose when I call them or not.)

I recommend studying other custom inventory and backpack systems to learn more about how they work. As an example:

1 Like

I made this one entirely out of folders which I am storing in each player. I’m not sure if that’s a good way to do it but I didn’t use any reference or tutorials and that’s what I thought of first.

(4 hotbars, 4 folders. I did it this way because I wanted you to be able to pick and choose your hotbars easily, so if you wanted to rearrange your inventory you could easily do so.)

Unfortunately the more customizable your inventory is, the more complicated it becomes to program and test. Personally I suggest sticking to the default backpack for now so you’ll be able to continue testing the rest of your game and in the meantime research and work on your custom inventory at your own pace in a different baseplate, then port it to your game once you have a version that works as you’d wish

1 Like

Honestly I do agree completely, BUT I feel like it has given me such motivation because it really shows you can make literally anything you want as long as you bugfix and think logically. My script works flawlessly now from what me and my friends have messed around with and tried to break, of course apart from tools which I’m just adding so it not working is a given.

1 Like

I wish I could continue helping you with this problem, but unfortunately I don’t have a custom inventory system that’s available for me to provide or is in a state where I could comfortably suggest. I noticed that the docs article about the default backpack provides useful information about the way it works behind the scenes which you can use to reverse-engineer its functionality for your inventory system:

Backpack | Documentation - Roblox Creator Hub

It’s not the inventory that’s the problem, never was.
It was actually the way I was grabbing the object which was the problem, it was a quick fix one I figured it out.

Thank you so much for your help! And one more question, Do you perhaps know how I would make the tool enable for anything other than left click? I was thinking of making it E to eat or use something like a bandage or a medkit. Thanks again!!!

1 Like

ContextActionService has a BindActivate method you can use to fire a Tool’s Activated event using a KeyCode or UserInputType:

1 Like

Gotcha, thanks and have a nice night!

1 Like

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