Humanoid:EquipTool() error

Hello! I have a script that is triggered from a remote event:

local event = game.ReplicatedStorage.EMF
event.OnServerEvent:Connect(function()

	local tool = game.Lighting.EMF

		for _, plr in pairs(game.Players:GetPlayers()) do
	
		coroutine.wrap(function() 
			local t = tool:clone()
			local char = plr.Character or plr.CharacterAdded:Wait()
			local hum = char:FindFirstChildOfClass("Humanoid") 
print("Worked up until equip")
			hum:EquipTool(t) 
			print("Worked equip")

		end)()
	end
	
end)
  • The script is located in a server script in a folder (workspace).

When it’s fired, the tool is not given to the player nor is it equipped.
image
Although, I have 0 errors.

The tool is located in lighting:
image

Any help is appreciated, thank you so much!

1 Like

Only duplicate the tool to

game.Players.PlayerName.Backpack

Or

workspace.PlayerName

Edit: the tool isnt game.Lighting.EMF but yed game.Lighting EMF:Clone(), or only the first player will get the item

And, you can get the player on .OnServerEvent:Connect(function(plr)

Would something like this look correct?

  coroutine.wrap(function() 
			local t = game.Players.PlayerName.Backpack:Clone(game.Lighting.EMF)
			local char = plr.Character or plr.CharacterAdded:Wait()
			local hum = char:FindFirstChildOfClass("Humanoid") 
            print("Worked up until equip")
			hum:EquipTool(t) 
			print("Worked equip")

No, try this on clone line

game.Lighting.EMF:Clone().Parent = game.Players.Playername.Backpack

And dont put the
hum:EquipTool()

(Sorry for dont format, Im on mobile and I cant be very time with keyboard on)

1 Like

local event = game.ReplicatedStorage.EMF
event.OnServerEvent:Connect(function(plr)

	local tool = game.Lighting.EMF

				
		local t = game.Lighting.EMF:Clone().Parent(game.Players.PlayerName.Backpack)

			local char = plr.Character or plr.CharacterAdded:Wait()
			local hum = char:FindFirstChildOfClass("Humanoid") 
            print("Worked up until equip")
			hum:EquipTool(t) 
			print("Worked equip")
			
			
			
		end)()
	end
	end)

Using this script prints an error:

When I say game.Players.PlayerName, Im saying the PlayerName has plr

game.Players.PlayerName.Backpack is the same than plr.Backpack

And u dont need to use " ( ) " on .Parent = only .Parent = plr.Backpack




local event = game.ReplicatedStorage.EMF
event.OnServerEvent:Connect(function(plr)

	local tool = game.Lighting.EMF

				
		local t = game.Lighting.EMF:Clone().Parent = plr.Backpack

			local char = plr.Character or plr.CharacterAdded:Wait()
			local hum = char:FindFirstChildOfClass("Humanoid") 
            print("Worked up until equip")
			hum:EquipTool(t) 
			print("Worked equip")
			
end)()
end
end)

So this should be right, correct?

No, before I said that

You dont need this

And why u have () after the end)?

isn’t the hum:EquipTool(t) required to make sure that it forces the player to equip the tool?

No, to force equip the tool only make instead of t:Clone().Parent = plr.Backpack

Make

t:Clone().Parent = char

1 Like

Ah, thank you! It works but does not force the player to equip.
image

local event = game.ReplicatedStorage.EMF
event.OnServerEvent:Connect(function(plr)

	local tool = game.Lighting.EMF


	local t = game.Lighting.EMF
	t:Clone().Parent = plr.Backpack
	local char = plr.Character or plr.CharacterAdded:Wait()
	local hum = char:FindFirstChildOfClass("Humanoid") 
	print("Worked up until equip")
--	hum:EquipTool(t) 
	print("Worked equip")

end)

Would you recommend using
hum:EquipTool(t)

my error, forgot this part, will adjust.

UPDATE

The script functions but gives players a tool PER player.

For example: if 2 users are in game, each user recieves two tools.

This is the script currently:

local event = game.ReplicatedStorage.EMF
event.OnServerEvent:Connect(function(plr)

	local tool = game.Lighting.EMF


	local t = game.Lighting.EMF
	t:Clone().Parent = plr.Backpack
	local char = plr.Character or plr.CharacterAdded:Wait()
	local hum = char:FindFirstChildOfClass("Humanoid") 
	hum:EquipTool(t) 
	
	
end)

Still unable to code this to work, any help is appreciated.