23 lines
No EOL
761 B
TypeScript
23 lines
No EOL
761 B
TypeScript
import { World, useEvent } from "@rbxts/matter"
|
|
import { Health, Model, PlayerCharacter } from "ReplicatedStorage/ecs/components"
|
|
import { getEvent } from "ReplicatedStorage/remotes"
|
|
|
|
getEvent("resetButton")
|
|
|
|
function customReset(world: World): void {
|
|
const resetButtonEvent = getEvent("resetButton")
|
|
for (const [, player] of useEvent(resetButtonEvent, "OnServerEvent")) {
|
|
for (const [id, playerCharacter, _model, health] of world.query(PlayerCharacter, Model, Health)) {
|
|
if (playerCharacter.player !== player) continue
|
|
world.insert(
|
|
id,
|
|
health.patch({
|
|
health: 0,
|
|
regeneration: 0
|
|
})
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
export = customReset |