F to Pick up items error. (Inventory system)

Hello, not too long ago I had created a simple “F to pick up” script and gui that corresponds as well as a inventory system. It worked great! The ability to pick up and store objects as well as drop them went smoothly; however, there was a catch. Part of the script that had dealt with picking up items only recognizes that of a singular part. I had tried making an object with various parts to resemble a log of wood rather than a part and it wouldn’t work although I had the right parameters inserted such as a bool value and such (Int value). It would mean a lot to me if I can receive any tips on this so I can further expand my knowledge on scripting in the future. Thanks!

First off. Could you show us the script?

Sure! give me a quick second, it may take a phew.

It seems like your inventory script only detects parts. Assuming you put your parts that made up the log in a model, add some code to your script that detects models too, and if a part is a child of a model, it is unable to be picked up.

Simply to put it, the pieces of wood for example are a singular part. I’m somewhat new to scripting and struggle how I can get the script to recognize all of the parameters you just listed. A solution I tried was putting an int value into the grouped object; however, to no avail it hadn’t worked. Im probably over complicating it.


This is my Remote handler for the remote event for picking up items and dropping them also.
Left click - Pick up
Right click - Drop
Toggle Inventory Gui - E

Wait wait wait. Shouldn’t player.Inventory be

player.Backpack

My apologies if there’s something else to that.

I think it set to inventory mainly due to that I made an Inventory also. It doesn’t update the leaderboards.

Hmmm. Maybe showing the script where the “inventory” folder is located inside the player may help.

oh boi, i remember when i was working with that thing before so:

This script will grab anything you wish, model, part, mesh, anything

How it works:
When you aim with the mouse, it will find the first StringValue inside it called:
“PickAble” , if pickable is FALSE or NIL, then it will not work

--Local Script

local item = Mouse.Target -- The is is what the mouse is marking
local plr = game.Players.LocalPlayer -- i forgot this
local Clicked = false -- Debounce system

local distancefromitem -- to see if the player is close enough

UIS.InputChanged:Connect(function()  -- Marker
	if Mouse.Target then
       if Mouse.Target:FindFirstChild("PickAble") then -- i forgot to add this
			item = Mouse.Target
			pickupgui.Adornee = item
			pickupgui.ObjectName.Text = item.StringName.Value
--As you can see, Above, we have a StringValue, the "Value" will 
--be the name of the item

			pickupgui.Enabled = true
		else -- aiming at something else, it will turn the marker off
			pickupgui.Adornee = nil
			pickupgui.Enabled = false
		end
	end
end)




UIS.InputEnded:Connect(function(input) -- Collects 
	
	if Clicked == true then
		print"Already Clicked on it"
		return
	end
	if input.KeyCode == Enum.KeyCode[C] then
		if Mouse.Target then
			if Mouse.Target:FindFirstChild("PickAble") then -- StringValue
				item = Mouse.Target
				
			
				
	distancefromitem = plr:DistanceFromCharacter(item.Position)
					
					if distancefromitem < 30 and Clicked == false and distancefromitem ~= nil then
				
					Clicked = true -- debounce
					
					YourRemoteHere:FireServer(item) 
					
					task.wait(1)
					Clicked = false
				
				end
			end
		end	
	end
end)

this was a quick example,
Sem título
–This will show the name of the item

and this:
is what i have inside the model/part/ or anything else:
Sem título

PickAble = true ( BoolValue )
StringName == Name of the item ( can be anything )

this works since my inventory system is based on that

3 Likes

Thanks so much! I’ll be sure to give this a try!

I should insert this into the remote handler right? Seeing that this is dealing with remote events.

remote events is necessary, so when the player picks up something, it will send
THE (Name of the item) (Wood) to the server

and the server will do some actions based on the name of the item


(Before you insert this, make sure it will not collide with any other variables, 
becaused this is functional already, you can adapt it, of course, but you must
pay attention on what you are doing )
1 Like

@Moleza, Thank you so much!! I think this was the exact solution I needed. I actually instead of grouping the two saw that making a union between the two objects and inserting these values made it work!! Thanks so much and I hope to start making my crafting and resource gathering game soon! (I also utilized the script you gave me)
Best wishes,
Lazarus

1 Like