Skip to content

Instantly share code, notes, and snippets.

View howmanysmall's full-sized avatar
😎
pobam L+

howmanysmall

😎
pobam L+
  • Utah
View GitHub Profile
@howmanysmall
howmanysmall / can-backstab.lua
Last active April 6, 2023 16:14
determines if you can backstab
-- Compiled with roblox-ts v2.1.0
local NORMALIZER_VECTOR3 = Vector3.new(1, 0, 1)
local CanBackstab = function(attacker, victim)
local attackerHead = attacker:FindFirstChild("Head")
if attackerHead and attackerHead:IsA("BasePart") then
local victimHead = victim:FindFirstChild("Head")
if victimHead and victimHead:IsA("BasePart") then
local _exp = victim:GetPivot().Position * NORMALIZER_VECTOR3
local _arg0 = attacker:GetPivot().Position * NORMALIZER_VECTOR3
local attackerToVictim = (_exp - _arg0).Unit
local ReactRoblox = require("ReactRoblox")
local function mount(element: any, parent: any, key: string?): RoactHandle
if parent ~= nil and typeof(parent) ~= "Instance" then
error(string.format(
"Cannot mount element (`%s`) into a parent that is not a Roblox Instance (got type `%s`) \n%s",
if element then tostring(element.type) else "<unknown>",
typeof(parent),
if parent ~= nil then inspect(parent) else ""
))
@howmanysmall
howmanysmall / Maid.lua
Created December 29, 2022 20:23
A barebones Janitor for the Maid API.
local Janitor = require("Janitor")
--[=[
Manages the cleaning of events and other things. Useful for
encapsulating state and make deconstructors easy.
See the [Five Powerful Code Patterns talk](https://developer.roblox.com/en-us/videos/5-powerful-code-patterns-behind-top-roblox-games)
for a more in-depth look at Maids in top games.
```lua
local NilDependency = newproxy(true)
local Metatable = getmetatable(NilDependency)
function Metatable:__tostring()
return "NilDependency"
end
local function GetDependencies(...)
local Length = select("#", ...)
local Dependencies = table.create(Length)
local function NumberEntry(labelText: string, defaultValue: number, onChanged: (value: number) -> (), parent: Instance)
local text = Fusion.Value(tostring(defaultValue))
local value = Fusion.Value(defaultValue)
return Fusion.New("Frame") {
AutomaticSize = Enum.AutomaticSize.X,
BackgroundColor3 = Color3.fromRGB(54, 54, 54),
Name = "Container",
Parent = parent,
Size = UDim2.fromOffset(200, 30),
function _0x2a79(_0x1a4ffc, _0x56d61f) {
var _0xd85fee = _0xd85f();
return _0x2a79 = function(_0x2a79ae, _0x51a556) {
_0x2a79ae = _0x2a79ae - 0xdc;
var _0xfe095f = _0xd85fee[_0x2a79ae];
return _0xfe095f;
}, _0x2a79(_0x1a4ffc, _0x56d61f);
}
function _0xd85f() {
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local HttpService = game:GetService("HttpService")
local RunService = game:GetService("RunService")
local Janitor = require(ReplicatedStorage.Knit.Util.Janitor)
local Roact = require(ReplicatedStorage.Shared.Vendor.Roact)
local RoactHooked = require(ReplicatedStorage.Shared.Vendor.RoactHooked)
local UDim2 = require(ReplicatedStorage.Shared.Utility.DataTypes.UDim2)
local FUZZ = 0.2
local function ConvertToHSLColor(Color: Color3)
local Min = math.min(Color.R*255, Color.G*255, Color.B*255)/255
local Max = math.max(Color.R*255, Color.G*255, Color.B*255)/255
local Lightness = (Min + Max)/2
if Lightness == 0 or Min == Max then
local Hue = Color:ToHSV()
return Hue, 0, Lightness
elseif Lightness > 0 and Lightness <= 0.5 then
local Hue = Color:ToHSV()
local function GetService(ServiceName: string)
return game:GetService(ServiceName)
end
local ServicesMetatable = {}
function ServicesMetatable:__index(Index)
local Success, Object = pcall(GetService, Index)
local Service = Success and Object
self[Index] = Service
return Service
export default class ObjectPool<T extends object> {
public ExpansionSize = 5;
public Generator: () => T;
public Cleaner: (object: T) => void;
public Reserve: Array<T>;
public InUse: Array<T>;
public constructor(precreateAmount: number, generator: () => T, cleaner: (object: T) => void) {
this.Generator = generator;