PHClass – Phantom Classes for Roblox Developers
Overview:
PHClass (PhantomClass) is a collection of custom, lightweight classes designed to extend Roblox’s default API. Each class behaves like a native Instance, with properties, methods, and events, but is fully scriptable and easy to use. PHClass allows developers to manage complex systems without cluttering the DataModel with extra Instances.
Currently included:
- Timeline: A time-based event manager (see below)
- RegionTrigger: Detect when NPCs, Users, or Objects enter and exit a 3D Space
- (Future classes: StateObject, Cooldown, Collection, etc.)
Classes
Timeline
Timeline Class
The Timeline class allows developers to create, control, and monitor timed sequences in their games. It includes features such as Play, Pause, Resume, and Ended events. Timeline is ideal for cutscenes, ability timers, animations, or any time-based logic.
Features:
- Play/Resume/Pause: Start, pause, or resume the timeline at any time
- Duration property: Set the total length of the timeline in seconds
- Ended event: Fires when the timeline completes; connects like a standard Roblox event
- Non-blocking or yielding behavior: Play can optionally yield until timeline completion
- Lightweight: Uses a Configuration instance for Explorer visibility but operates fully in Lua
Usage Example:
local PHClass = require(game.ServerScriptService.PHClass)
local Timeline = PHClass.Instance.new("Timeline", workspace)
Timeline.Duration = 5
Timeline.Ended:Connect(function()
print("Timeline ended!")
end)
Timeline:Play()
task.wait(2)
Timeline:Pause()
print("Timeline paused at 2 seconds")
task.wait(2)
Timeline:Resume()
print("Timeline resumed")
Expected Output:
Timeline paused at 2 seconds
Timeline resumed
Timeline ended! -- Fires after remaining time
API Reference:
Properties:
- Duration (number) – Total length of the timeline
- Running (boolean) – Whether the timeline is currently running
Methods:
- Play() – Starts the timeline
- Pause() – Pauses the timeline
- Resume() – Resumes the timeline from where it left off
Events:
- Ended – Fires when the timeline completes
RegionTrigger
PHRegion – RegionTrigger Class for PHClass
Overview:
PHRegion (RegionTrigger) is a PHClass module that detects when players, NPCs, or objects enter or leave a defined 3D area. It is designed to be lightweight, fully scriptable, and easy to integrate with the PHClass system. Regions can move, resize, and filter events based on tags or object types.
Features:
- Detect PlayerEntered, PlayerLeft, ObjectEntered, ObjectLeft
- Dynamic regions that can move or resize
- Event-based API, works like Roblox events
- Lightweight: Uses a Configuration instance but operates fully in Lua
- Easy integration with PHClass.Instance.new(“RegionTrigger”, parent)
Usage Example:
local PHClass = require(game.ServerScriptService.PHClass)
local Region = PHClass.Instance.new("RegionTrigger", workspace)
Region.Position = Vector3.new(0,5,0)
Region.Size = Vector3.new(20,10,20)
Region.PlayerEntered:Connect(function(player)
print(player.Name.." entered the region!")
end)
Region.PlayerLeft:Connect(function(player)
print(player.Name.." left the region!")
end)
Region.ObjectEntered:Connect(function(object)
print(object.Name.." entered!")
end)
Region.ObjectLeft:Connect(function(object)
print(object.Name.." left!")
end)
API Reference:
Properties:
- Position (Vector3) – Center of the region
- Size (Vector3) – Dimensions of the region
- Enabled (boolean) – Whether the region is active
Methods:
- SetPosition(Vector3) – Update the center position
- SetSize(Vector3) – Update the region size
- Enable() – Enable the region
- Disable() – Disable the region
Events:
- PlayerEntered – Fires when a player enters the region
- PlayerLeft – Fires when a player leaves the region
- ObjectEntered – Fires when any object (BasePart) enters the region
- ObjectLeft – Fires when any object leaves the region
Use Cases:
- Safe zones
- Quest or dungeon areas
- Triggering cutscenes, spawns, or buffs
- Proximity-based effects
PHClass is designed to be easily extendable. Future classes can be registered and used through PHClass.Instance.new(“ClassName”, parent), giving developers a flexible and unified API for custom behaviors in Roblox games.
Additionally, you can easily implement your own custom classes using our current class module.