Damage GUI/Sound Module

Hi guys, it’s me again! This module is just something I created out of boredom, this can probably use a lot of improvement though. When you insert the model of it into the workspace, there will be a folder called “Hurt Module”. If you look inside of it there will be three folders, “StarterCharacterScripts”, “ReplicatedStorage”, and “StarterGui”. There are items inside of those folders, and each item goes into the category its folder was named(the gui and sounds can be replaced by you). Now I will go over the module functions. You will need to insert a LocalScript into StarterCharacterScripts.

Variables
You will need these variables in your script first.

local Player = game.Players.LocalPlayer
local HurtModule = require(game.ReplicatedStorage:WaitForChild("HurtModule"))
local Humanoid = script.Parent:WaitForChild("Humanoid")
local HurtSound = script.Parent:WaitForChild("Heartbeat")
local HurtGUI = Player.PlayerGui:WaitForChild("Blood"):WaitForChild("BloodImage") --not necessary

We will need these variables to actually use the module, but the damage GUI is optional.

Checking Player Health
We need to check the player health to know if the player is at or under the interval for the sound and/or for the hurt GUI to appear, so we do this.

Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
	HurtModule.CheckHealth(Humanoid,HurtSound)
end)

Every time the humanoid’s health changes, we will use a function in the module called “CheckHealth” to make sure if the sound and/or GUI should appear.

Setting Up Hurt GUI (Not Necessary)

To do this we just use this simple function from the module.

HurtModule.SetUpGUI(HurtGUI)

Now there will be a GUI when the player’s health is at or goes under the set interval.
(THE GUI MUST BE A IMAGELABEL)
Changing Health Interval

If you look in the Hurt Module there is a variable called “PAIN_INTERVAL” and it is set to 50. You can set the value to whatever you want as long as it is above 0.

I may make a more polished version with more features if people want me to. If you have any bugs or questions, please tell/ask me. Thanks for reading!
(the sound and GUI is tweened, there is a variable that has tween information for each one, you can change the tween duration to any number as long as its above 0. you can replace the GUI and sound if you want, they were just there as a template.)

Module: Hurt Module - Roblox

Video: https://youtu.be/aASJLHJ0jxo

Test Place: Hurt Module Test Place - Roblox

9 Likes