FastTouched
About
- Fast Touched is a Hitbox Module which allows users to make Hitboxes quick and easy!
Why use it?
- Efficient and Fast.
- Beginner Friendly
Where to download?
- Download will always be in the same thread if it gets updated!
Credits
- 1christian#0001 { Providing w/ Ideas and helping making the base. }
I’m not providing examples on how to use it’s in the lua script.
local Players = game:GetService("Players")
local Shared = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local HttpService = game:GetService("HttpService")
local HitboxModule = {
Settings = {
Event = Shared.Remotes.Hit,
ShowHitboxes = true,
HitMessage = "", --// Leave as "" for no message!
},
Defaults = {
Offset = Vector3.new(0,0,0),
Size = 5,
Length = 1,
Damage = 0,
},
}
---Checks if the part 'Hit' is a client
---@param Hit BasePart
function HitboxModule:IsHuman(Hit: BasePart)
return (Hit.Parent:FindFirstChildOfClass("Humanoid") and true) or false
end
--- Creates a hitbox for 'Length' seconds on the 'Character' based on the 'Character' RootPart position multiplied by the offset
---@param Player Player
---@param Character Model
---@param Offset Vector3
---@param Size number
---@param Length number
---@param Damage number
function HitboxModule:CreateHitbox(Player: Player, Character: Model, Offset: Vector3, Size: number, Length: number, Damage: number)
local Hitboxes = Instance.new("Folder", Character)
Hitboxes.Name = "ArchMageOwO_"..HttpService:GenerateGUID(false)
local HeartbeatConnection: RBXScriptConnection|nil
local TouchedConnection: RBXScriptConnection|nil
--- Disconnects all RBXScriptConnections and destroys any remaining parts
local function DisconnectAll()
if (HeartbeatConnection) then
HeartbeatConnection:Disconnect()
end
if (TouchedConnection) then
TouchedConnection:Disconnect()
end
Hitboxes:Destroy()
end
HeartbeatConnection = RunService.RenderStepped:Connect(function(deltaTime)
local Part: BasePart = Instance.new("Part", Hitboxes)
Part.CanTouch = true
Part.CanCollide = false
Part.CastShadow = false
Part.Anchored = true
Part.CFrame = Character.PrimaryPart.CFrame * (Offset or self.Defaults.Offset)
Part.Transparency = (self.Settings.ShowHitboxes and 0.5) or 1
Part.Name = deltaTime * math.random(10000,50000) .. HttpService:GenerateGUID(false)
TouchedConnection = Part.Touched:Connect(function(Hit: BasePart)
if self:IsHuman(Hit) then
if (self.Settings.HitMessage ~= "") then
print(self.Settings.HitMessage)
end
self.Settings.Event:FireServer(Hit.Parent, Damage) --// Add your own arguements to the event!
DisconnectAll()
end
end)
Part:Destroy()
end)
task.delay(Length or self.Defaults.Length, function()
DisconnectAll()
end)
end
return HitboxModule