Skip to content

Commit 24432e2

Browse files
committed
fix: don't make invicibility change health
1 parent 9470b80 commit 24432e2

2 files changed

Lines changed: 3 additions & 35 deletions

File tree

src/server/services/character.ts

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,11 @@
11
import { Service, type OnInit } from "@flamework/core";
2-
import { Players } from "@rbxts/services";
3-
import { endsWith } from "@rbxts/string-utils";
42

5-
import type { OnCharacterAdd } from "shared/hooks";
63
import { Events } from "server/network";
74

8-
import type { DatabaseService } from "./third-party/database";
9-
105
@Service()
11-
export class CharacterService implements OnInit, OnCharacterAdd {
12-
public constructor(
13-
private readonly db: DatabaseService
14-
) { }
15-
6+
export class CharacterService implements OnInit {
167
public onInit(): void {
178
Events.character.toggleDefaultMovement.connect((player, on) => this.toggleDefaultMovement(player, on));
18-
this.db.updated.Connect((player, directory, value) => {
19-
if (!endsWith(directory, "settings/invincibility")) return;
20-
this.updateInvincibility(player, false, <boolean>value);
21-
});
22-
}
23-
24-
public onCharacterAdd(character: CharacterModel): void {
25-
const player = Players.GetPlayerFromCharacter(character)!;
26-
this.updateInvincibility(player);
27-
}
28-
29-
public updateInvincibility(player: Player, justPurchased = false, settingOverride?: boolean): void {
30-
const humanoid = (player.Character ?? player.CharacterAdded.Wait()[0]).FindFirstChildOfClass("Humanoid");
31-
if (humanoid === undefined) return;
32-
33-
const ownsPass = justPurchased || this.db.ownsInvincibilityPass(player);
34-
const enabled = ownsPass && (settingOverride ?? this.db.get<boolean>(player, "settings/invincibility"));
35-
humanoid.Health = enabled ? math.huge : 100;
36-
humanoid.MaxHealth = enabled ? math.huge : 100;
379
}
3810

3911
public toggleDefaultMovement(player: Player, on: boolean): void {

src/server/services/transactions.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,11 @@ export class TransactionsService implements OnInit, LogStart {
4242
[ProductIDs.Coins25000]: player => this.db.increment(player, "coins", 25000),
4343

4444
[PassIDs.InfiniteCoins]: player => this.db.set(player, "coins", math.huge),
45-
[PassIDs.Invincibility]: player => {
46-
player.SetAttribute("OwnsInvincibility", true);
47-
this.character.updateInvincibility(player, true);
48-
}
45+
[PassIDs.Invincibility]: player => player.SetAttribute("OwnsInvincibility", true)
4946
}
5047

5148
public constructor(
52-
private readonly db: DatabaseService,
53-
private readonly character: CharacterService
49+
private readonly db: DatabaseService
5450
) { }
5551

5652
public onInit(): void {

0 commit comments

Comments
 (0)