Server character restructure

This commit is contained in:
2024-04-20 15:05:43 -04:00
parent 4baf7bff51
commit b82606d64c
21 changed files with 2 additions and 2 deletions

60
src/client/UI/Health.lua Normal file
View File

@@ -0,0 +1,60 @@
--!optimize 2
--!native
--!strict
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
type Impl_Constructor = {
__index: Impl_Constructor,
constructor: Constructor_Fun,
--Class functions
Enable: (self: ClassConstructor) -> (),
Disable: (self: ClassConstructor) -> (),
DisplayHealth: (self: ClassConstructor, Amount: number) -> (),
} & Impl_Static_Props
type Impl_Static_Props = {
Enabled: boolean
}
type Constructor_Fun = (PlayerGui: PlayerGui) -> ClassConstructor
type Constructor_Return_Props = {
HealthGui: ScreenGui,
Amount: TextLabel
}
local HealthModule = {} :: Impl_Constructor
HealthModule.__index = HealthModule
HealthModule.Enabled = false
function HealthModule.constructor(PlayerGui: PlayerGui)
local HealthGui = PlayerGui:WaitForChild("Health") :: ScreenGui
local Amount = HealthGui:WaitForChild("Amount") :: TextLabel
return setmetatable({
HealthGui = HealthGui,
Amount = Amount
}, HealthGui)
end
function HealthModule:Enable()
HealthModule.Enabled = true
end
function HealthModule:Disable()
HealthModule.Enabled = false
end
function HealthModule:DisplayHealth(Amount: number)
self.Amount.Text = tostring(Amount)
if Amount <= 40 then
self.Amount.TextColor3 = Color3.fromRGB(255,238,0)
elseif Amount <= 20 then
self.Amount.TextColor3 = Color3.fromRGB(255,0,38)
else
self.Amount.TextColor3 = Color3.new(1,1,1)
end
end
return HealthModule