Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can you use EquipTools() without causing an error?

I am not that good at scripting, especially when tracking down errors . That is why I want to ask you for help

here is a bit of the code:

game.Players.PlayerAdded:connect(function(Player)
	Player.CharacterAdded:connect(function(Character)
		repeat wait() until Character.Humanoid
		local Humanoid = Character:WaitForChild("Humanoid")
		Humanoid.Died:Connect(function()
			Player:LoadCharacter()
			repeat wait() until Character.Humanoid
			wait(2)
			local hum = Character:WaitForChild("Humanoid")
			if Player.TeamColor == BrickColor.new("Bright blue") then			
				Character:WaitForChild("Humanoid"):EquipTool(Player.Backpack:WaitForChild("M4A1-S"))
			elseif Player.TeamColor == BrickColor.new("Bright yellow") then
				Character:WaitForChild("Humanoid"):EquipTool(Player.Backpack:WaitForChild("AK47"))
			end
		end)
	end)
end)

I tried multiple ways of fixing it but I always end with the same results:

UnequipTools can only be called on a Humanoid with a corresponding Player object.

It's been annoying me. I will be glad if you are able to help me out a bit.

1 comment

0

you could just parent the tool to the charcter.... e.g.. tool.Parent = player.Character

1 answer

✓ Accepted answer

I had the same problem as well for a long time! But for some reason you can't use a variable to equip the tool!

Try this:

game.Players.PlayerAdded:connect(function(Player)
    Player.CharacterAdded:connect(function(Character)
        repeat wait() until Character.Humanoid
        local Humanoid = Character:WaitForChild("Humanoid")
        Humanoid.Died:Connect(function()
            Player:LoadCharacter()
            repeat wait() until Character.Humanoid
            wait(2)
            local hum = Character:WaitForChild("Humanoid")
            if Player.TeamColor == BrickColor.new("Bright blue") then           
 game.Players.LocalPlayer.Character:WaitForChild("Humanoid"):EquipTool(Player.Backpack:WaitForChild("M4A1-S"))

elseif Player.TeamColor == BrickColor.new("Bright yellow") then
                game.Players.LocalPlayer.Character:WaitForChild("Humanoid"):EquipTool(Player.Backpack:WaitForChild("AK47"))
            end
        end)
    end)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.