1 | local player = game.Players.LocalPlayer |
2 | |
3 | if player.Character then |
4 | local humanoid = player.Character:WaitForChild("Humanoid") |
5 | local previousHealth = humanoid.Health |
6 | |
7 | humanoid.Changed:Connect(function() |
8 | if humanoid.Health < previousHealth then |
9 | local randomIndex = math.random(1, #getgenv().hurtmessages) |
10 | local message = getgenv().hurtmessages[randomIndex] |
11 | |
12 | game:GetService("ReplicatedStorage").DefaultChatSystemChatEvents.SayMessageRequest:FireServer(message, "All") |
13 | end |
14 | |
15 | previousHealth = humanoid.Health |
16 | end) |
17 | end |
18 | |
19 | player.CharacterAdded:Connect(function(char) |
20 | local humanoid = char:WaitForChild("Humanoid") |
21 | local previousHealth = humanoid.Health |
22 | |
23 | humanoid.Changed:Connect(function() |
24 | if humanoid.Health < previousHealth then |
25 | local randomIndex = math.random(1, #getgenv().hurtmessages) |
26 | local message = getgenv().hurtmessages[randomIndex] |
27 | |
28 | game:GetService("ReplicatedStorage").DefaultChatSystemChatEvents.SayMessageRequest:FireServer(message, "All") |
29 | end |
30 | |
31 | previousHealth = humanoid.Health |
32 | end) |
33 | end) |