Tool Removing once Equipped..?

Basically I want my tool to create its handle once equipped. Before you ask, the reason I don’t just start with a handle is because it needs to alter other parts outside of the tool based off of the current handle, which if I only have one (A handle pre-placed into the tool), screws up the timing (That is besides the point).

The problem occurring is shortly after I equip my tool, most likely caused by the handle creation function, it removes the tool completely from my backpack and character. Is this a built-in feature when a part named “Handle” is created? I am not sure. Secondly, the created handle doesn’t even appear in hand.

Edit: To clarify, there is no line in my script in which it tells the tool to be removed or reparented.

Here is a clip of my problem:

Here is the code in which I think it causes the problem:

local function MakeKnife()
	local NewHandle = Instance.new("Part")
	
	NewHandle.Name = "Handle"
	NewHandle.BrickColor = Appearance.BrickColor
	NewHandle.Material = Appearance.Material
	NewHandle.Transparency = Appearance.Transparency
	NewHandle.Reflectance = Appearance.Reflectantce
	NewHandle.CanCollide = false
	
	local Mesh = Instance.new("SpecialMesh")
	
	Mesh.MeshType = Enum.MeshType.FileMesh
	Mesh.MeshId = Appearance.MeshId
	Mesh.TextureId = Appearance.TextureId
	Mesh.Scale = Appearance.Scale
	Mesh.Offset = Appearance.Offset
	Mesh.Parent = NewHandle
	
	return NewHandle
end

Knife.Equipped:connect(function()
	Equipped = true
	
	CurrentHandle = MakeKnife()
	CurrentHandle.Parent = Knife
	
	if LocalPlayer then
		local Character = LocalPlayer.Character
		
		if Character then
			local KnifeHolder = Character:FindFirstChild("KnifeHolder")
			
			if KnifeHolder then
				coroutine.resume(coroutine.create(function()
					wait(0.1)
					
					if Equipped and CurrentHandle then
						KnifeHolder.Transparency = 1
						CurrentHandle.Transparency = Appearance.Transparency
					end
				end))
			end
		end
	end
end)

Any suggestions would be very much appreciated. Thanks for reading. Have a good day!

  • Galactiq
3 Likes

if there are any other scripts check if they do anything to the character, player backpack or tool

In the OnSpawn function, it creates the knife and adds it to the players’ backpack. I don’t see why that would affect it, though. Also, the problem occurred before I even made this part of the script. I originally had the tool placed in StarterPack, but moved it in an attempt to fix the problem. No luck…

Here is the code that adds the knife to the backpack:

local function GiveKnife(Player,Type)
	local nm = Player.Name
	
	if _G.PlayerData[nm] then
		local EquippedKnife = _G.PlayerData[nm].Data.Equipped.Knife
		local Appearance = Knives:FindFirstChild(EquippedKnife):FindFirstChild("Appearance")
		local Sounds = Knives:FindFirstChild(EquippedKnife):FindFirstChild("Sounds")
		local NewKnife = GameWeapons:FindFirstChild("Knives"):FindFirstChild(Type):Clone()
		
		Appearance:Clone().Parent = NewKnife
		Sounds:Clone().Parent = NewKnife
		NewKnife.Parent = Player.Backpack
	end
end

local function OnSpawn(Player)
	local Character = Player.Character or Player.CharacterAdded:wait()
	
	wait()
	
	TeleportToLobby(Character,Player)
	ApplyWeapons(Character,Player)
	GiveKnife(Player,"Knife")
	
	repeat wait() until _G.DataManagerReady
	
	if _G.DataManager["PlayerHasItem"](Player,"Radio","Default") then
		ApplyRadio(Character,Player)
	end
	
	wait(1)
	ApplyCharacter(Character,Player)
end
1 Like

Check if its deleted. If not Knife.Equipped:Destroy

1 Like

So do you want me to check when the Equipped event is called to see if it is actually equipped??

So. You are not deleting the item from the game. It would be like saying. When knife is equipped then unequipped then destroy.(Not code)

Well, see, the tool itself is deleted without me unequipping it. That is why I am confused by it.

1 Like

No. As shown in the video, I equip the knife. It waits roughly 0.1 seconds (the time before it creates the handle), and then removes the tool. I just now equipped it and paused all scripts before it removed it. I found that it does create a handle, but it doesn’t put it in the characters’ right hand.

if Equipped and CurrentHandle then
KnifeHolder.Transparency = 1 – What?
CurrentHandle.Transparency = Appearance.Transparency
end
end))
end
end
end
end)

KnifeHolder.Transparency = 1 is changing that it looks like you deleted it

That isn’t important. I just found that it removes any tool that does not have a handle when created. So I put a test tool in with just a blank part not named handle, and then it removed after I equipped. However, when I named it Handle it didn’t. So maybe I will just have to have it start with a handle??

1 Like

I need to say thirty words so that might be the bug in your problem

Thanks for your responses. I have solved my problem. I created a handle in the tool, and then the new handles are just welded to the starter handle. Have a good day!

1 Like