# @rbxts/promise-character

> Promise all members of a character rig exist, then dot access!

Latest version **1.0.3** (published 2021-10-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install @rbxts/promise-character
pnpm add @rbxts/promise-character
yarn add @rbxts/promise-character
bun add @rbxts/promise-character
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2021-10-11 |
| First published | 2021-10-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 24.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 20 |
| Author | Validark |
| Maintainers | validark |
| Keywords | character, dot, Roblox, Player, yield, wait, members, parts, promise |

## Links

- npm: https://www.npmjs.com/package/@rbxts/promise-character
- Repository: https://github.com/Validark/Roblox-TS-Libraries.git#master
- Homepage: https://github.com/Validark/Roblox-TS-Libraries/blob/master/promise-character/README.md
- Issues: https://github.com/Validark/Roblox-TS-Libraries/issues
- npm.io page: https://npm.io/package/@rbxts/promise-character

## Dependencies (3)

- [@rbxts/types](https://npm.io/package/@rbxts/types.md) ^1.0.537
- [@rbxts/validate-tree](https://npm.io/package/@rbxts/validate-tree.md) ^2.0.1
- [@rbxts/compiler-types](https://npm.io/package/@rbxts/compiler-types.md) ^1.2.3-types.1

## Alternatives

- [promise-throttle](https://npm.io/package/promise-throttle.md) — 44.2K weekly downloads
- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2021-10-11
- 1.0.2 — 2021-10-10
- 1.0.1 — 2021-10-10
- 1.0.0 — 2021-10-10

## README

# promise-character

Usage:

Pass a Player's Character `Model` into `promiseR15` or `promiseR6`, which will promise via `promiseTree` from `validate-tree` that all the members defined in the R6/R15 trees exist (all members except those generated by Sound/Animate scripts).

```ts
promiseR15(character).then(char => {
	// All members are properly typed and defined!
	char.Head.face.Texture = ""
});

// alternatively, one may use `await`
async function f() {
	const char = await promiseR15(character);
	char.Head.face.Texture = ""
}
```

Here is what I envision as a practical use for this library:

```ts
import {
	promiseR6,
	promiseR15,
	CharacterRigR15,
	CharacterRigR6,
} from "@rbxts/promise-character";

import { Players } from "@rbxts/services";
import { promiseChildOfClass } from "@rbxts/promise-child";

function doStuffWithR15(rig: CharacterRigR15) {
	rig.RightFoot.Destroy();
}

function doStuffWithR6(rig: CharacterRigR6) {
	rig["Left Arm"].Destroy();
}

async function handleCharacterModel(model: Model) {
	const rigType = (await promiseChildOfClass(model, "Humanoid")).RigType.Name;

	if (rigType === "R15") {
		const rig15 = await promiseR15(model);
		rig15.Head.Neck.Destroy(); // R15 specific logic :)
		doStuffWithR15(rig15);
	} else if (rigType === "R6") {
		const rig6 = await promiseR6(model);
		rig6.Torso.Destroy(); // R6 specific logic :)
		doStuffWithR6(rig6);
	} else {
		throw `${model.Name} has an unknown rig type! ${rigType}`;
	}
}

Players.PlayerAdded.Connect(({ Name, Character, CharacterAdded }) => {
	print(`Welcome, ${Name}`);
	if (Character) handleCharacterModel(Character);
	CharacterAdded.Connect(handleCharacterModel);
});
```

---
_Source: https://npm.io/package/@rbxts/promise-character · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
