Weird tool handle issue

Hey devforum, I need some help fixing a problem with tool handles:

After I join the game, or after I die, when I equip a tool for the first time, the handle is invisible, I have to unequip it and equip it again for it to start showing up. After I die or rejoin, it happens again.

https://gyazo.com/4b06848f7f19c6c6d10725ca9234cb51

This is the script I am using to equip the tool:

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

local userI = game:GetService("UserInputService")

local tool = script.Parent.Value

userI.InputBegan:Connect(function(input, gameP)
	if gameP then return end
	if input.KeyCode == Enum.KeyCode.One then
		if tool.Parent ~= character then
			local insideStuff = character:GetChildren()
			
			for i, v in pairs(insideStuff) do
				if v.ClassName == "Tool" then
					v.Parent = player.Backpack
				end
			end
			
			tool.Parent = character
		elseif tool.Parent ~= player.Backpack then
			tool.Parent = player.Backpack
		end
	end
end)

script.Parent.Parent.Number1Frame.TextButton.MouseButton1Click:Connect(function()
	if tool.Parent ~= character then
		local insideStuff = character:GetChildren()

		for i, v in pairs(insideStuff) do
			if v.ClassName == "Tool" then
				v.Parent = player.Backpack
			end
		end

		tool.Parent = character
	elseif tool.Parent ~= player.Backpack then
		tool.Parent = player.Backpack
	end
end)

script.Parent.Value:GetPropertyChangedSignal("Parent"):Connect(function()
	if script.Parent.Value.Parent ~= player.Backpack then
		script.Parent.Parent.Number1.BackgroundTransparency = 0
		script.Parent.Parent.Number1Frame.BackgroundTransparency = 0
	else
		script.Parent.Parent.Number1.BackgroundTransparency = 0.4
		script.Parent.Parent.Number1Frame.BackgroundTransparency = 0.4
	end
end)

Thanks for reading!

I think it’s because when you die, some stuff in the script messes up.

script.Parent.Value:GetPropertyChangedSignal("Parent")

Instead of this, try using script.Parent.Value.AncestryChanged since it’s a dedicated event which fires whenever a parent changes of an instance.

Other than that, I don’t really see anything here which could change the tool’s transparency.
Maybe you have some other scripts somewhere, and they change it?

Have a nice day

1 Like