Parenting a tool's handle to the workspace results in it disappearing after a another part was the main part

When I pick up a part, I change the name of it to “Handle” so the player’s character will move its arm in the default tool position. However, when picking up a different part and dropping it, it disappears but the original one persists. I’m open to alternate ways of handling this pickup system but for now it is the easiest way for me to get the base idea of my game down. (also feel free to shame my horrid skills)

I would like to make it so the part is dropped out of your player’s hand and fall to the ground and not disappear. Simple.



Server Script

game.ReplicatedStorage.Remotes.EquipPart.OnServerEvent:Connect(function(player, part)
	if player.Character:FindFirstChild("Holding") then
		part.Parent = player.Character.Holding
		part.Name = "Handle"
		part.CanCollide = false
		part.Anchored = false
	end
end)

game.ReplicatedStorage.Remotes.DropPart.OnServerEvent:Connect(function(player, part)
	if player.Character:FindFirstChild("Holding") then
		local part = player.Character.Holding:FindFirstChild("Handle")
		
		if part then
			part.Name = part:GetAttribute("OriginalName")
			part.CanCollide = true
			part.Anchored = true
			part.Parent = game.Workspace.Interactable
			part.Position += part.CFrame.LookVector * 3
			part.Anchored = false
		end
	end
end)

Client Script

if input.KeyCode == Enum.KeyCode.F then
	if player.Character.Holding:FindFirstChild("Handle") then
		game.ReplicatedStorage.Remotes.DropPart:FireServer(objectTarget)
	elseif objectTarget:GetAttribute("Grabbable") == true and objectTarget ~= nil then
		game.ReplicatedStorage.Remotes.EquipPart:FireServer(objectTarget)
	end
end

So far, I’ve tried recreating the entire script and still persists, I’ve researched similar posts but nothing was related.

2 Likes

Code looks alright seems to be just weirdness with network ownership perhaps the part position is not updating server side?

I would suggest cframing it in front of the humanoid rootpart to see if it makes a difference.

Also perhaps try destroying the tool grip weld as well since you are doing unequipping manually.

.CFrame = hrp.CFrame + lookVector

1 Like

That didn’t help BUT I did find out it seems to occur once the part is unanchored. I added a wait to the unanchor part and it still disappears just later… (duh)

1 Like

I know a few other alternate ways of pick up systems, what is it used for? Just so I can recommend you the best way.
(Also, I’m definitely not going to shame your amazing skills.)

Currently I’m creating a horror+puzzle game w/ my friend. It’ll be used for picking up items like keys and using them. Also some fun stuff to mess around with. Mostly just using this way because I cannot animate for crap.

1 Like

Would you rather use tools or just weld it to the player. (Tools means you could equip it, weld means it’s always showing)

Welding would probably be easier at this point for how simple I need it.

Then inside the part, add a script that makes it so that when you click it it welds to the players hand, I can type it out for you if you want but it’ll take like 5-10 mins

1 Like

No it’s alright! I’ve got a general idea of how to do that. Thank you!

1 Like

No worries, just let me know if you are stuck or want me to write it out, I’ve got free time and wouldn’t mind helping!

Again, I’d like to thank you. I actually learned how much I’m liking welds more!

No problem, I also started a lot using them after I found out what they could do!

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