Tool visible while not equipped?

So I was wondering about if it’s possible to have a part inside of the tool visible while the tool is not equipped. I know this article is very short but I would really like an answer :slight_smile:

I dont think thats possible but what can u do is when the player joins u weld a part to him (the part u want visible) and then when u equip the tool u make that part invisible with an event

1 Like

In general, the tool should be visible on the player when it is in the Backpack, I might guess?

  • Tool is not equipped, but in the player’s inventory. —> Show the tool, because it’s hidden in Backpack and needs to be visible
  • Tool is equipped, in the player’s hands. —> Hide the tool, because it’s not hidden in the Backpack any more, it’s already visible in the player’s hands (so to speak)
  • Tool is just chilling somewhere on the ground. —> Don’t be attached to any character

It follows that whenever the Tool enters a Backpack, it should show itself on the character, and hide itself when it leaves the Backpack.

local tool = script.Parent
local lastParent = nil

-- Runs every time the Parent of the Tool changes
function onParentChanged()
	local parent = tool.Parent
	if parent == lastParent then return end -- Do none of the following if nothing happened
	if lastParent:IsA("Backpack") then makeToolInvisibleOnPlayer(lastParent.Parent) end
	if     parent:IsA("Backpack") then   makeToolVisibleOnPlayer(    parent.Parent) end
	lastParent = parent
end

function makeToolVisibleOnPlayer(player)
	-- Your code
	-- You can use player.Character to get the blocky guy that the player moves around
	-- Be careful, player.Character can be nil
	-- So you may have to do:
	-- local character = player.Character or player.CharacterAdded:wait()
	-- to guarantee it exists (nothing will run after that line until there is a character
	-- If you choose to straight up move all the parts in the tool to the character and
	-- weld it to the player, then test dropping the tool before you publish :)
end

function makeToolInvisibleOnPlayer(player)
	-- Your code
	-- Runs immediately before makeToolVisibleOnPlayer if the Tool was in a backpack
end

-- Make it work
tool:GetPropertyChangedSignal("Parent"):Connect(onParentChanged)

-- Run the function for the first time so it can act immediately
-- when it is freshly created and put in a backpack, or the script is activated
-- It will seem like the Tool had moved from nil to where it is at the moment
onParentChanged()

None of this code is actually tested