Skip to content

Instantly share code, notes, and snippets.

View Sleitnick's full-sized avatar

Stephen Leitnick Sleitnick

View GitHub Profile
local coolSword = game:GetService("ReplicatedStorage").Assets.Swords.CoolSword
@Sleitnick
Sleitnick / ClosestPickup.lua
Created September 26, 2023 15:02
Custom spatial query test
--!native
--!optimize 2
--[[
ClosestPickup
- LocalScript inside StarterCharacterScripts
- MAX_RADIUS is not really a radius, but rather the zone cube size
- It searches for BaseParts in the workspace with the 'Pickup' tag
- It assumes BasePart; non BaseParts with the same tag will break this test
@Sleitnick
Sleitnick / Find.lua
Created August 31, 2023 13:28
Find an instance within the Roblox game hierarchy starting at a given parent. Throws an error if not found. Optional IsA check.
--!strict
--[[
Find(parent: Instance, path: string, [assertIsA: string]): Instance
e.g.
child = Find(parent, "ChildName")
child = Find(parent, "ChildName", "BasePart")
child = Find(parent, "ChildName/Some/Nested/Object")
child = Find(parent, "ChildName/Some/Nested/Object", "BasePart")
-- Run in LocalScript context.
-- Move mouse around to see Input event ordering in the output as well.
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local lastT = 0
local function FmtTime()
local t = time()
-- MyService.lua
local MyService = {}
function MyService:DoSomething()
print("Do something")
end
return MyService
----------------------------
local MyService = {}
return MyService
-- Load all ModuleScripts within 'MyModules' that end with "Service" & call their OnStart methods.
Loader.SpawnAll(
Loader.LoadDescendants(MyModules, Loader.MatchName("Service$")),
"OnStart"
)
--[[
Copyright © 2022 Stephen Leitnick
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the “Software”), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions
of the Software.
@Sleitnick
Sleitnick / Log.lua
Created April 20, 2021 20:12
A logger for Lua based on Google's Flogger
-- Log
-- Stephen Leitnick
-- April 20, 2021
--[[
IMPORTANT: Only make one logger per script/module
Log.Level { Debug, Info, Warn, Severe }
@Sleitnick
Sleitnick / Platform.lua
Created November 7, 2018 15:47
Platform creator
-- Platform
-- Crazyman32
-- November 6, 2018
--[[
This should be a LocalScript within StarterCharacterScripts.
This creates platform parts as the player runs around. It does
not replicate the platforms to other players. So only the local