I know I'm probably using wrong a tool, but I'm trying to use a tool like a button instead of as a tool.

So, when a player use equip the tool, the tool call a remote function:

local actionListener = tool.ActionListener
local inTransition = false

local function onEquip()
	if not inTransition then
		inTransition = true
		
		--HERE IS CALL THE REMOTE FUNCTION
		actionListener:InvokeServer()
		--HERE IS CALL THE REMOTE FUNCTION

		inTransition = false
	end
end

tool.Equipped:Connect(onEquip)

and the server script do some procedures and change the parent of the tool

local tool = --this is an instance of the tool that the player have
local remoteFunction= tool.actionListener

function remoteFunction.OnServerInvoke()

	--do some procedures

	tool.Parent = player.Backpack
end

But I receive this error:

Something unexpectedly tried to set the parent of Toolbox to Backpack while trying to set the parent of Toolbox. Current parent is Player1.

I am not sure where is the problem, but probably is because I am using the tool as a button instead of a tool.

So, the initial question is: How to unequip tool from server script?

Any help would be appreciated.

3 comments

0

You might want to look at the :UnequipTools() function of humanoid.

1

You've never specified player in the InvokeServer

0

Always important to assign Player/player/ply/something.