diff --git a/Kit/Managers/CharacterManager/PhysicsFixer.local.luau b/Kit/Managers/CharacterManager/PhysicsFixer.local.luau index 04bf4cf..bd3f44b 100644 --- a/Kit/Managers/CharacterManager/PhysicsFixer.local.luau +++ b/Kit/Managers/CharacterManager/PhysicsFixer.local.luau @@ -19,11 +19,10 @@ Thank you local Players = game:GetService("Players") local RunService = game:GetService("RunService") -local character = Players.LocalPlayer.Character or Players.LocalPlayer.CharacterAdded:Wait() -local humanoid: Humanoid? = character:WaitForChild("Humanoid") -if not humanoid then - return -end +local localPlayer = Players.LocalPlayer :: Player + +local character = localPlayer.Character or localPlayer.CharacterAdded:Wait() +local humanoid = character:WaitForChild("Humanoid") :: Humanoid -- Head collision glitch fix local head = character:FindFirstChild("Head") @@ -34,7 +33,7 @@ if head and head:IsA("BasePart") then end -- Truss Fix --- Original script by AkaWhats (& some help by MasSpartan) +-- Original script by AkaWhats (& some help by Nullspace) -- Code touchups & some micro-optimizations done by synnwave local DEFAULT_FPS = 1 / 60 @@ -55,8 +54,8 @@ local STATES = { [Enum.HumanoidStateType.Running] = false, } -local fps -local function onStateChanged(oldState, newState) +local fps: number +local function onStateChanged(oldState: Enum.HumanoidStateType, newState: Enum.HumanoidStateType) if newState ~= oldState and STATES[newState] then for state, allowed in STATES do if allowed and state ~= newState then diff --git a/Kit/Managers/CharacterManager/TypeDefs.luau b/Kit/Managers/CharacterManager/TypeDefs.luau index a21493d..af4366d 100644 --- a/Kit/Managers/CharacterManager/TypeDefs.luau +++ b/Kit/Managers/CharacterManager/TypeDefs.luau @@ -17,8 +17,6 @@ Thank you local ReplicatedStorage = game:GetService("ReplicatedStorage") -local GuiManager = ReplicatedStorage.Framework.Kit.Managers.GuiManager - export type __VALID_DAMAGEBRICKS = { kills: number, double: number, @@ -72,7 +70,7 @@ export type BoostData = { power: number, priority: number?, - frame: typeof(GuiManager.BoostFrame)?, -- created later + frame: typeof(ReplicatedStorage.Framework.Kit.Managers.GuiManager.BoostFrame)?, -- created later module: Boost, extraVariables: {[string]: any}, @@ -101,7 +99,7 @@ export type CharacterManager = { -- damage functions Damage: (self: CharacterManager, damage: BasePart | number | string) -> (), - ValidateDamageBrick: (self: CharacterManager, brick: BasePart) -> (number | string)?, + ValidateDamageBrick: (self: CharacterManager, brick: BasePart) -> ((number | string)?, number?), -- helper functions GetHumanoid: (self: CharacterManager, player: Player) -> Humanoid?, diff --git a/Kit/Managers/CharacterManager/init.luau b/Kit/Managers/CharacterManager/init.luau index 5281fb2..87dafa9 100644 --- a/Kit/Managers/CharacterManager/init.luau +++ b/Kit/Managers/CharacterManager/init.luau @@ -117,7 +117,7 @@ Functions function CharacterManager:ValidateDamageBrick(brick: BasePart) local damageAmount: (number | string)? if brick:GetAttribute("Activated") == false then - return + return nil, nil end local configuration = brick:FindFirstChild("DamageBrickConfiguration") @@ -151,7 +151,7 @@ function CharacterManager:Damage(damage: BasePart | string | number) return end - local cooldown = 0 + local cooldown: number local damageAmount: (number | string)? if typeof(damage) == "Instance" and damage:IsA("BasePart") then damageAmount, cooldown = CharacterManager:ValidateDamageBrick(damage) @@ -162,7 +162,7 @@ function CharacterManager:Damage(damage: BasePart | string | number) if not damageAmount then return end - if cooldown > 0 and typeof(damage) == "Instance" then + if (cooldown or 0) > 0 and typeof(damage) == "Instance" then damageCooldown[damage] = true task.delay(cooldown, function() damageCooldown[damage] = false @@ -180,7 +180,7 @@ end function CharacterManager:GetHumanoid(player: Player): Humanoid? local character = player.Character if not character then - return + return nil end return character:FindFirstChildOfClass("Humanoid") @@ -193,7 +193,7 @@ end A `TweenInfo` can be provided to tween the value. ]=] function CharacterManager:ChangeHumanoidProperty(property: string, value: any, tweenInfo: TweenInfo?) - local humanoid = CharacterManager:GetHumanoid(Players.LocalPlayer) + local humanoid = CharacterManager:GetHumanoid(Players.LocalPlayer :: Player) if not humanoid then return end @@ -326,7 +326,7 @@ function CharacterManager:StartBoost(boostData: _TDefs.BoostData) if boostData.mode == "Default" then --handle regular boosters boostData.infinite = CharacterManager:IsBoostInfinite(boostData) - local boostLoop + local boostLoop: RBXScriptConnection boostLoop = RunService.Heartbeat:Connect(function() local activeBoostData = CharacterManager:GetActiveBoost(boostData.type, boostData.mode) diff --git a/Kit/Managers/ClientObjectManager/init.luau b/Kit/Managers/ClientObjectManager/init.luau index 3a1ac65..db8b67c 100644 --- a/Kit/Managers/ClientObjectManager/init.luau +++ b/Kit/Managers/ClientObjectManager/init.luau @@ -60,11 +60,11 @@ local function traverseFolders(folder: Instance, repository: Repo, startingPath: continue end - local cached = requireCache[instance] + local cached: (ScopeTypes.LegacyRepositoryModule | ScopeTypes.RepositoryModule)? = requireCache[instance] if not requireCache[instance] then -- requires already cache but i think it'l be a bit more -- performant doing this - local loadSuccess, loadReturns = pcall(require, instance) + local loadSuccess, loadReturns: (ScopeTypes.LegacyRepositoryModule | ScopeTypes.RepositoryModule)? = pcall(require, instance) if not loadSuccess then Log({ `Failed to load repository script "{path}"`, @@ -278,7 +278,7 @@ function ClientObjectManager:Init() local property = if i == 2 then "LocalTransparencyModifier" else "Transparency" for _, instance in CollectionService:GetTagged(tag) do if instance:IsA("BasePart") then - instance[property] = 1 + (instance :: any)[property] = 1 end end diff --git a/Kit/Managers/FlipManager/init.luau b/Kit/Managers/FlipManager/init.luau index e137e87..b28d2bd 100644 --- a/Kit/Managers/FlipManager/init.luau +++ b/Kit/Managers/FlipManager/init.luau @@ -71,7 +71,7 @@ Functions --------------------------------------------------------------------------- ]] -local localPlayer = Players.LocalPlayer +local localPlayer = Players.LocalPlayer :: Player local flipCooldowns = {} @@ -100,7 +100,7 @@ function FlipManager:TryFlip() return end - for _, touchingPart: BasePart in Workspace:GetPartsInPart(torso, PARAMS) do + for _, touchingPart in Workspace:GetPartsInPart(torso, PARAMS) do if ( not touchingPart:HasTag("CanFlip") @@ -118,16 +118,16 @@ function FlipManager:TryFlip() flipCooldowns[touchingPart] = nil end) - local teleportPart = touchingPart + local teleportPart: BasePart = touchingPart if not touchingPart:HasTag("DoNotFlipPlayer") then local teleportToObject = touchingPart:FindFirstChild("TeleToObject") if teleportToObject and teleportToObject:IsA("ObjectValue") and teleportToObject.Value - and teleportToObject.Value:IsA("BasePart") + and (teleportToObject.Value :: Instance):IsA("BasePart") then - teleportPart = teleportToObject.Value + teleportPart = teleportToObject.Value :: BasePart elseif teleportToObject then warn("blank", teleportToObject, "value") return @@ -174,7 +174,7 @@ function FlipManager:BindToFlip(part: BasePart, callback: (rootPart: BasePart) - end local callbacks = FlipManager.__callbacks - local callbackID = HttpService:GenerateGUID() + local callbackID: string? = HttpService:GenerateGUID() if not callbacks[part] then callbacks[part] = {} end diff --git a/Kit/Managers/GuiManager/init.luau b/Kit/Managers/GuiManager/init.luau index cc4ada3..213dcfd 100644 --- a/Kit/Managers/GuiManager/init.luau +++ b/Kit/Managers/GuiManager/init.luau @@ -45,6 +45,8 @@ local Log = require(Framework.Log) local CharacterManager_Types = require(Kit.Managers.CharacterManager.TypeDefs) local KitSettings = require(ReplicatedStorage.KitSettings) +local localPlayer = Players.LocalPlayer :: Player + --[[ --------------------------------------------------------------------------- Main table @@ -88,9 +90,9 @@ end Creates and returns a boost timer frame for the given `boostType`. ]=] -function GuiManager:CreateBoostFrame(boostData: CharacterManager_Types.BoostData): _TDefs.BoostTimerFrame +function GuiManager:CreateBoostFrame(boostData: CharacterManager_Types.BoostData): _TDefs.BoostTimerFrame? if boostData.hideGUI then - return -- don't make one if they disabled it + return nil-- don't make one if they disabled it end boostID += 1 @@ -116,7 +118,7 @@ function GuiManager:CreateBoostFrame(boostData: CharacterManager_Types.BoostData frame.LayoutOrder = -boostID frame.Parent = GuiManager.Gui.Boosts - boostData.frame = frame + boostData.frame = frame :: _TDefs.BoostTimerFrame? TweenService:Create(frame, BOOST_FRAME_TWEEN_INFO, { Size = script.BoostFrame.Size }):Play() GuiManager:UpdateBoostFrame(boostData) @@ -216,7 +218,7 @@ function GuiManager:__updateKeyDisplay() end local characterCFrame - local character = Players.LocalPlayer.Character + local character = (Players.LocalPlayer :: Player).Character if character then characterCFrame = character:GetPivot() end @@ -295,24 +297,22 @@ end ]=] function GuiManager:DisplayGUI(guiName: string, ...: any) local gui = script:FindFirstChild(guiName) - if not gui then -- already being displayed? + if not gui or not gui:IsA("ScreenGui") then -- already being displayed? Log({ `{guiName} GUI not found or already visible!!`, type = "warn", }) - - return true + return end if guiName == "debug" then local displayMemory = ... - gui.memory.Visible = displayMemory - gui.memory.LocalScript.Enabled = displayMemory + (gui :: typeof(script.debug)).memory.Visible = displayMemory + do (gui :: typeof(script.debug)).memory.LocalScript.Enabled = displayMemory end end gui.Enabled = true gui.Parent = GuiManager.PlayerGui - return true end function GuiManager:Init() @@ -321,17 +321,16 @@ function GuiManager:Init() end self.__initialized = true - local localPlayer = Players.LocalPlayer - local playerGui = localPlayer:WaitForChild("PlayerGui") + local playerGui = localPlayer:WaitForChild("PlayerGui") :: PlayerGui task.spawn(function() - GuiManager.Gui = playerGui:WaitForChild("EffectGUI", 5) + GuiManager.Gui = playerGui:WaitForChild("EffectGUI", 5) :: index<_TDefs.GuiManager, "Gui"> end) GuiManager.PlayerGui = playerGui --> Detect any new EffectGUIs playerGui.ChildAdded:Connect(function(child) if child.Name == "EffectGUI" then - GuiManager.Gui = child + GuiManager.Gui = child :: index<_TDefs.GuiManager, "Gui"> end end) diff --git a/Kit/Managers/ScopeConstructor/TypeDefs.luau b/Kit/Managers/ScopeConstructor/TypeDefs.luau index e870a49..9f8fcff 100644 --- a/Kit/Managers/ScopeConstructor/TypeDefs.luau +++ b/Kit/Managers/ScopeConstructor/TypeDefs.luau @@ -54,7 +54,7 @@ export type ScopeCommunicator = typeof(setmetatable({} :: __Communicator_params, ----------------------------------------- --> Scope Types -export type RepositoryModule = { Run: (scope: Scope, repository: any) -> (), [string]: any } +export type RepositoryModule = { Run: (scope: Scope, repository: any) -> (), Init: ((utility: any) -> ())?, [string]: any } export type LegacyRepositoryModule = (scope: Scope, repository: any) -> () export type __Scope_params = { diff --git a/Kit/Repository/Interactables/BoostRemover/init.luau b/Kit/Repository/Interactables/BoostRemover/init.luau index 77ef99d..d67bc92 100644 --- a/Kit/Repository/Interactables/BoostRemover/init.luau +++ b/Kit/Repository/Interactables/BoostRemover/init.luau @@ -29,14 +29,10 @@ local BoostRemover = { RunOnStart = false, } -local REMOVER_CONFIG_TEMPLATE -function BoostRemover.Init(utility: _T.Utility) - local Config = utility.Config - REMOVER_CONFIG_TEMPLATE = { - Type = "Unknown", - Mode = "", - } -end +local REMOVER_CONFIG_TEMPLATE = { + Type = "Unknown", + Mode = "", +} local SequencerSupport = require(script.SequencerSupport) local function setupCache(rootScope: _T.Scope, utility: _T.Utility) diff --git a/Kit/Repository/Interactables/Booster/init.luau b/Kit/Repository/Interactables/Booster/init.luau index 1850461..d9d15f0 100644 --- a/Kit/Repository/Interactables/Booster/init.luau +++ b/Kit/Repository/Interactables/Booster/init.luau @@ -28,19 +28,19 @@ local _T = require(ReplicatedStorage.Framework.ClientTypes) local CharacterManager_Types = require(ReplicatedStorage.Framework.Kit.Managers.CharacterManager.TypeDefs) local SequencerSupport = require(script.SequencerSupport) -type Booster = { +type Booster = { hitbox: BasePart, configuration: { [string]: any }, extraVariables: { [string]: any}, - startTweenConfig: { [string]: any }, - endTweenConfig: { [string]: any }, + startTweenConfig: T, + endTweenConfig: T, id: string, } -type BoosterCache = { +type BoosterCache = { activators: { [BasePart]: () -> () }, - boosters: { Booster }, - activeBoosters: { [string]: Booster? }, + boosters: { Booster }, + activeBoosters: { [string]: Booster }, } local Booster = { @@ -93,7 +93,7 @@ function Booster.Run(scope: _T.Scope, utility: _T.Utility) else {} --> Functions - local function getBoostData(booster: Booster): CharacterManager_Types.BoostData? + local function getBoostData(booster: Booster): CharacterManager_Types.BoostData? local boostModule = CharacterUtil.getBoostModule(booster.configuration.Type) if not boostModule then return nil @@ -137,7 +137,7 @@ function Booster.Run(scope: _T.Scope, utility: _T.Utility) CharacterUtil.getHitbox("StaticWholeBody", overlapParams) local cache = utility.Scope.getCached(scope, scope.scriptPath, function() - local cache: BoosterCache = { + local cache: BoosterCache = { activators = {}, boosters = {}, activeBoosters = {}, @@ -161,7 +161,7 @@ function Booster.Run(scope: _T.Scope, utility: _T.Utility) lastTick = currentTick --> Get touching parts and determine if any zone boosters are being touched - local touchingBoosters: { Booster } = {} + local touchingBoosters: { Booster } = {} for _, booster in cache.boosters do if #Workspace:GetPartsInPart(booster.hitbox, overlapParams) > 0 @@ -230,7 +230,7 @@ function Booster.Run(scope: _T.Scope, utility: _T.Utility) end --> Main functionality - local boosterData: Booster = { + local boosterData: Booster = { hitbox = booster, configuration = configuration, extraVariables = extraVariables, diff --git a/Kit/Repository/Interactables/BouncePad.luau b/Kit/Repository/Interactables/BouncePad.luau index 5359455..b2c6d58 100644 --- a/Kit/Repository/Interactables/BouncePad.luau +++ b/Kit/Repository/Interactables/BouncePad.luau @@ -29,15 +29,11 @@ local BouncePad = { RunOnStart = false, } -local PAD_CONFIG_TEMPLATE -function BouncePad.Init(utility: _T.Utility) - local Config = utility.Config - PAD_CONFIG_TEMPLATE = { - Power = 100, - Cooldown = 0.05, - RelativeForce = false, - } -end +local PAD_CONFIG_TEMPLATE = { + Power = 100, + Cooldown = 0.05, + RelativeForce = false, +} function BouncePad.Run(scope: _T.Scope, utility: _T.Utility) --> Setup @@ -79,11 +75,15 @@ function BouncePad.Run(scope: _T.Scope, utility: _T.Utility) cooldownActive = false end) - if Players:GetPlayerFromCharacter(part.Parent) == player then - part = player.Character.PrimaryPart - + if utility.ClientObjects.validatePlayerToucher(part, touchConfiguration.playerHitboxMode) then + local charparts = utility.Character.getCharacter() + + local rootPart = charparts.rootPart + if rootPart then + part = rootPart + end -- fix velocity sometimes being weird - local humanoid = utility.Character.getHumanoid() + local humanoid = charparts.humanoid if humanoid then humanoid:ChangeState(Enum.HumanoidStateType.Freefall) end diff --git a/Kit/Repository/Interactables/Button/init.luau b/Kit/Repository/Interactables/Button/init.luau index 89d1772..88ea8e6 100644 --- a/Kit/Repository/Interactables/Button/init.luau +++ b/Kit/Repository/Interactables/Button/init.luau @@ -92,21 +92,17 @@ local Button = { Communicator = COMMUNICATOR, } -local BUTTON_CONFIG_TEMPLATE -function Button.Init(utility: _T.Utility) - local Config = utility.Config - BUTTON_CONFIG_TEMPLATE = { - Timer = 0, - TimerDecimalPlaces = 1, - TimerText = "{T}", - PressOffset = CFrame.new(Vector3.yAxis * 0.75), - PressedMaterial = Config.Type.Enum(Enum.Material.Neon), - HideGUI = false, - - PadMode = false, - PadDistance = 5, - } -end +local BUTTON_CONFIG_TEMPLATE = { + Timer = 0, + TimerDecimalPlaces = 1, + TimerText = "{T}", + PressOffset = CFrame.new(Vector3.yAxis * 0.75), + PressedMaterial = Enum.Material.Neon, + HideGUI = false, + + PadMode = false, + PadDistance = 5, +} type ConfigTemplate = typeof(BUTTON_CONFIG_TEMPLATE) type Button = _TDefs.Button @@ -206,11 +202,11 @@ local function handleButtonCache(rootScope: _T.Scope, utility: _T.Utility): Butt local function handleNewPlatform(platform: BasePart) local this = {} :: typeof(TAGS) cache.ButtonActivatedPlatforms[platform] = this - for key in pairs(TAGS) do -- we love broken type inference + for key in TAGS do -- we love broken type inference this[key] = platform:HasTag(key) end if not this.IgnoreInitialActivate then - task.defer(activatePlatform, platform, false) + task.defer(activatePlatform, platform, false, nil) end end @@ -218,7 +214,7 @@ local function handleButtonCache(rootScope: _T.Scope, utility: _T.Utility): Butt if not tagFilter(platform) then continue end - handleNewPlatform(platform) + handleNewPlatform(platform :: BasePart) end rootScope:add(CollectionService:GetInstanceAddedSignal(PLATFORM_TAG):Connect(function(instance) if not tagFilter(instance) or not instance:IsA("BasePart") then @@ -376,12 +372,12 @@ function Button.Run(scope: _T.Scope, utility: _T.Utility) cache.Buttons[buttonPart] = nil end) - local timerLabel = buttonConfig:FindFirstChildWhichIsA("TextLabel") + local timerLabel = buttonConfig:FindFirstChildWhichIsA("TextLabel") :: TextLabel? local function updatePlatforms(pressed: boolean?) -- don't deactivate if there's a different button of the same color active -- this is to match v5.5 behavior - + if not pressed then for _, otherButton in cache.Buttons do if diff --git a/Kit/Repository/Interactables/JumpLauncher.luau b/Kit/Repository/Interactables/JumpLauncher.luau index 5018ad3..7c9c621 100644 --- a/Kit/Repository/Interactables/JumpLauncher.luau +++ b/Kit/Repository/Interactables/JumpLauncher.luau @@ -31,18 +31,14 @@ local JumpLauncher = { RunOnStart = false, } -local LAUNCHER_CONFIG_TEMPLATE -function JumpLauncher.Init(utility: _T.Utility) - local Config = utility.Config - LAUNCHER_CONFIG_TEMPLATE = { - Cooldown = 0.25, - Force = 60, - SizeReduction = Vector3.one, - Transparency = Config.Type.number, - } -end +local LAUNCHER_CONFIG_TEMPLATE = { + Cooldown = 0.25, + Force = 60, + SizeReduction = Vector3.one, + Transparency = math.nan, +} -local player = Players.LocalPlayer +local player = Players.LocalPlayer :: Player local function handleCache(rootScope: _T.Scope, utility: _T.Utility) local cache = { playerBuffering = false, @@ -102,7 +98,7 @@ function JumpLauncher.Run(scope: _T.Scope, utility: _T.Utility) local configuration = Config.GetConfig(scope, launcherConfig, LAUNCHER_CONFIG_TEMPLATE):ObserveChanges() local touchConfiguration = Config.GetConfig(scope, launcherConfig:FindFirstChild("TouchConfiguration"), Config.TOUCH_CONFIG) - :ObserveChanges() + :ObserveChanges() --> Model Setup local soundsFolder = jumpLauncher:FindFirstChild("Sounds") @@ -202,7 +198,7 @@ function JumpLauncher.Run(scope: _T.Scope, utility: _T.Utility) utility.Functions.playSoundFromInstance(jumpLauncher, soundsFolder, "Bounce") local targetTransparency = if invisible then 1 - else configuration.Transparency or originalTransparency + else (if not math.isnan(configuration.Transparency) then configuration.Transparency else originalTransparency) jumpLauncher.Transparency = if invisible then 1 else targetTransparency / 4 utility.Functions.tween(jumpLauncher, 0.5, { Transparency = targetTransparency }) if bounceParticle then diff --git a/Kit/Repository/Interactables/KeyGroup/init.luau b/Kit/Repository/Interactables/KeyGroup/init.luau index 725788e..ff12ecc 100644 --- a/Kit/Repository/Interactables/KeyGroup/init.luau +++ b/Kit/Repository/Interactables/KeyGroup/init.luau @@ -78,22 +78,16 @@ local KeyGroup = { RunOnStart = false, } -local KEY_CONFIG_TEMPLATE -local DOOR_CONFIG_TEMPLATE - -function KeyGroup.Init(utility: _T.Utility) - local Config = utility.Config - KEY_CONFIG_TEMPLATE = { - SpinSpeed = 5, - Timer = 0, - TimerDecimalPlaces = 1, - ViewportOffset = CFrame.identity, - TimerText = "{T}", - } - DOOR_CONFIG_TEMPLATE = { - RequiredKeys = 1, - } -end +local KEY_CONFIG_TEMPLATE = { + SpinSpeed = 5, + Timer = 0, + TimerDecimalPlaces = 1, + ViewportOffset = CFrame.identity, + TimerText = "{T}", +} +local DOOR_CONFIG_TEMPLATE = { + RequiredKeys = 1, +} local _TDefs = require(script.TypeDefs) type Key = _TDefs.Key diff --git a/Kit/Repository/Interactables/Morpher/init.luau b/Kit/Repository/Interactables/Morpher/init.luau index 56cff47..2d52b45 100644 --- a/Kit/Repository/Interactables/Morpher/init.luau +++ b/Kit/Repository/Interactables/Morpher/init.luau @@ -31,17 +31,17 @@ local Morpher = { RunOnStart = false, } -local BUTTON_CONFIG_TEMPLATE +local BUTTON_CONFIG_TEMPLATE = { + Timer = 0, + TimerText = "{T}", + TimerDecimalPlaces = 1, + CarryObjects = true, +} local TOUCH_CONFIGURATION local TWEEN_CONFIGURATION function Morpher.Init(utility: _T.Utility) local Config = utility.Config - BUTTON_CONFIG_TEMPLATE = { - Timer = 0, - TimerText = "{T}", - TimerDecimalPlaces = 1, - CarryObjects = true, - } + TOUCH_CONFIGURATION = Config.TOUCH_CONFIG TWEEN_CONFIGURATION = Config.TWEEN_CONFIG end diff --git a/Kit/Repository/Interactables/MusicZoneEditor/init.luau b/Kit/Repository/Interactables/MusicZoneEditor/init.luau index aaecdbf..ba76c76 100644 --- a/Kit/Repository/Interactables/MusicZoneEditor/init.luau +++ b/Kit/Repository/Interactables/MusicZoneEditor/init.luau @@ -34,15 +34,11 @@ local MusicZoneEditor = { RunOnStart = false, } -local EDITOR_CONFIG_TEMPLATE -function MusicZoneEditor.Init(utility: _T.Utility) - local Config = utility.Config - EDITOR_CONFIG_TEMPLATE = { - ZoneName = "", - OneTimeUse = false, - Cooldown = 1, - } -end +local EDITOR_CONFIG_TEMPLATE = { + ZoneName = "", + OneTimeUse = false, + Cooldown = 1, +} local SequencerSupport = require(script.SequencerSupport) local function handleCache(rootScope: _T.Scope, utility: _T.Utility) diff --git a/Kit/Repository/Interactables/Sequencer/init.luau b/Kit/Repository/Interactables/Sequencer/init.luau index ba2584b..5e43df2 100644 --- a/Kit/Repository/Interactables/Sequencer/init.luau +++ b/Kit/Repository/Interactables/Sequencer/init.luau @@ -132,28 +132,22 @@ local Sequencer = { Communicator = COMMUNICATOR, } -local SEQUENCER_CONFIG_TEMPLATE -local MUSIC_SYNC_CONFIG_TEMPLATE -local STOPPER_CONFIG_TEMPLATE -function Sequencer.Init(utility: _T.Utility) - local Config = utility.Config - SEQUENCER_CONFIG_TEMPLATE = { - LoopAmount = 0, - LoopDelay = 0, - Cooldown = 0, - Speed = 1, - Visualize = false, - RunAtStart = false, - HideSequence = false, - } - MUSIC_SYNC_CONFIG_TEMPLATE = { - ZoneName = Config.Type.string, - SyncEnabled = false, - } - STOPPER_CONFIG_TEMPLATE = { - BreakLoop = false, - } -end +local SEQUENCER_CONFIG_TEMPLATE = { + LoopAmount = 0, + LoopDelay = 0, + Cooldown = 0, + Speed = 1, + Visualize = false, + RunAtStart = false, + HideSequence = false, +} +local MUSIC_SYNC_CONFIG_TEMPLATE = { + ZoneName = "", + SyncEnabled = false, +} +local STOPPER_CONFIG_TEMPLATE = { + BreakLoop = false, +} local musicManager function Sequencer.Run(scope: _T.Scope, utility: _T.Utility) @@ -210,7 +204,7 @@ function Sequencer.Run(scope: _T.Scope, utility: _T.Utility) local syncConfiguration = Config.GetConfig(scope, musicSyncConfig, MUSIC_SYNC_CONFIG_TEMPLATE):ObserveChanges() local syncData - if musicSyncConfig and syncConfiguration.SyncEnabled and syncConfiguration.ZoneName then + if musicSyncConfig and syncConfiguration.SyncEnabled then local syncPointer = utility.Instance.getPointer(musicSyncConfig:FindFirstChild("Sync")) if syncPointer then syncData = utility.SongTime.BuildSyncCache(require(syncPointer) :: any) diff --git a/Kit/Repository/Mountables/Attacher/init.luau b/Kit/Repository/Mountables/Attacher/init.luau index 3dbec5e..0b3e0c3 100644 --- a/Kit/Repository/Mountables/Attacher/init.luau +++ b/Kit/Repository/Mountables/Attacher/init.luau @@ -44,19 +44,15 @@ local BANNED_STATES = { [Enum.HumanoidStateType.RunningNoPhysics] = true, } -local ATTACHER_CONFIG_TEMPLATE -function Attacher.Init(utility: _T.Utility) - local Config = utility.Config - ATTACHER_CONFIG_TEMPLATE = { - AttachUsingAlign = false, - Cooldown = 0.5, - CleanDelay = 0, - DismountState = Config.Type.Enum(Enum.HumanoidStateType.Jumping), - DismountStateEnabled = true, - Offset = CFrame.new(0, 0, -5), - WeldToLimb = Config.Type.Enum(Enum.Limb.Torso), - } -end +local ATTACHER_CONFIG_TEMPLATE = { + AttachUsingAlign = false, + Cooldown = 0.5, + CleanDelay = 0, + DismountState = Enum.HumanoidStateType.Jumping, + DismountStateEnabled = true, + Offset = CFrame.new(0, 0, -5), + WeldToLimb = Enum.Limb.Torso, +} local function getLimb(character: Instance?, hitPart: BasePart, limb: Enum.Limb): BasePart? if not character or not limb then diff --git a/Kit/Repository/Physics/OneWayPlatform.luau b/Kit/Repository/Physics/OneWayPlatform.luau index 48e910b..111dec4 100644 --- a/Kit/Repository/Physics/OneWayPlatform.luau +++ b/Kit/Repository/Physics/OneWayPlatform.luau @@ -44,17 +44,13 @@ local OneWayPlatform = { local ACTIVE_KEY = "OneWayPlatform_Activated" local ACTIVE_CHECK_IGNORES = { [ACTIVE_KEY] = true } -local PLATFORM_CONFIG_TEMPLATE -function OneWayPlatform.Init(utility: _T.Utility) - local Config = utility.Config - PLATFORM_CONFIG_TEMPLATE = { - SetActivated = true, - Offset = CFrame.identity, - ActiveTransparency = Config.Type.number, - InactiveTransparency = Config.Type.number, - ActivateConnectedParts = false, - } -end +local PLATFORM_CONFIG_TEMPLATE = { + SetActivated = true, + Offset = CFrame.identity, + ActiveTransparency = math.nan, + InactiveTransparency = math.nan, + ActivateConnectedParts = false, +} local function handleCache(rootScope: _T.Scope, utility: _T.Utility) local cache = {} :: PlatformCache @@ -83,8 +79,8 @@ local function handleCache(rootScope: _T.Scope, utility: _T.Utility) local active = data.Active and upVector:Dot(look) > 0 local originalTransparency = data.OriginalTransparency local transparency = if active - then data.ActiveTransparency or originalTransparency - else data.InactiveTransparency or originalTransparency + then (if not math.isnan(data.ActiveTransparency) then data.ActiveTransparency else originalTransparency) + else (if not math.isnan(data.InactiveTransparency) then data.InactiveTransparency else originalTransparency) for _, otherPart in data.Parts do if otherPart.CanCollide ~= active then diff --git a/Kit/Repository/Visual/BeatBlock.luau b/Kit/Repository/Visual/BeatBlock.luau index 31fb295..fc2847f 100644 --- a/Kit/Repository/Visual/BeatBlock.luau +++ b/Kit/Repository/Visual/BeatBlock.luau @@ -28,35 +28,30 @@ local BeatBlock = { RunOnStart = false, } -local BEATBLOCK_CONFIG_TEMPLATE -local MUSIC_SYNC_CONFIG_TEMPLATE -function BeatBlock.Init(utility: _T.Utility) - local Config = utility.Config - BEATBLOCK_CONFIG_TEMPLATE = { - ChangeCanTouch = true, - Indicator = true, - IndicatorSize = Vector3.new(3, 3, 3), - IndicatorScaleMultiplier = 1, - MaterialIndicator = Config.Type.Enum(Enum.Material.SmoothPlastic), - - OffCanCollide = false, - OffTransparency = 0.5, - OffCanTouch = false, - - OnCanCollide = true, - OnTransparency = 1, - OnCanTouch = true, - - Interval = 1, - IndicatorInterval = 0.5, - - ToggleChildren = false, - } - MUSIC_SYNC_CONFIG_TEMPLATE = { - ZoneName = Config.Type.string, - SyncEnabled = false, - } -end +local BEATBLOCK_CONFIG_TEMPLATE = { + ChangeCanTouch = true, + Indicator = true, + IndicatorSize = Vector3.new(3, 3, 3), + IndicatorScaleMultiplier = 1, + MaterialIndicator = Enum.Material.SmoothPlastic, + + OffCanCollide = false, + OffTransparency = 0.5, + OffCanTouch = false, + + OnCanCollide = true, + OnTransparency = 1, + OnCanTouch = true, + + Interval = 1, + IndicatorInterval = 0.5, + + ToggleChildren = false, +} +local MUSIC_SYNC_CONFIG_TEMPLATE = { + ZoneName = "", + SyncEnabled = false, +} local REFRESH_RATE = 1 / 60 @@ -108,7 +103,7 @@ function BeatBlock.Run(scope: _T.Scope, utility: _T.Utility) local syncConfiguration = Config.GetConfig(scope, musicSyncConfig, MUSIC_SYNC_CONFIG_TEMPLATE):ObserveChanges() local syncData - if syncConfiguration.SyncEnabled and syncConfiguration.ZoneName then + if syncConfiguration.SyncEnabled then local syncPointer = utility.Instance.getPointer(musicSyncConfig:FindFirstChild("Sync")) if syncPointer then syncData = utility.SongTime.BuildSyncCache(require(syncPointer) :: any) diff --git a/Kit/Repository/Visual/Emitter/init.luau b/Kit/Repository/Visual/Emitter/init.luau index 80774b3..f5b5356 100644 --- a/Kit/Repository/Visual/Emitter/init.luau +++ b/Kit/Repository/Visual/Emitter/init.luau @@ -36,15 +36,15 @@ local Emitter = { RunOnStart = false, } -local EMITTER_CONFIG_TEMPLATE +local EMITTER_CONFIG_TEMPLATE = { + GlobalSound = true, + Uses = 0, -- refreshes when changed + Cooldown = 1, +} local EMMISSION_CONFIG_TEMPLATE function Emitter.Init(utility: _T.Utility) local Config = utility.Config - EMITTER_CONFIG_TEMPLATE = { - GlobalSound = true, - Uses = math.huge, -- refreshes when changed - Cooldown = 1, - } + EMMISSION_CONFIG_TEMPLATE = { EmitCount = Config.Type.Some(Config.Type.number, Config.Type.NumberRange, Config.Type.none), EmitDelay = 0, diff --git a/Kit/Utility/Character.luau b/Kit/Utility/Character.luau index 3797e78..01549b5 100644 --- a/Kit/Utility/Character.luau +++ b/Kit/Utility/Character.luau @@ -28,11 +28,13 @@ local Character = {} local Framework = ReplicatedStorage.Framework local Managers = Framework.Kit.Managers +local localPlayer = Players.LocalPlayer :: Player + Character.HitboxModes = table.freeze({ "StaticWholeBody", "StaticCenter", "StaticArms", "RootPart", "WholeBody", "Center" }) export type HitboxModes = "StaticWholeBody" | "StaticCenter" | "StaticArms" | "RootPart" | "WholeBody" | "Center" | string -local function _addToListAndFilter(part, list, params: OverlapParams?) +local function _addToListAndFilter(part: BasePart, list: {BasePart}, params: OverlapParams?) table.insert(list, part) if typeof(params) == "OverlapParams" then params:AddToFilter(part) @@ -47,13 +49,13 @@ end function Character.getHitbox(mode: HitboxModes, params: OverlapParams?): { BasePart } local parts = {} - local character = Players.LocalPlayer.Character + local character = localPlayer.Character if not character then return parts end if mode == "RootPart" or mode:find("Static") then - local hitbox = character:FindFirstChild("_HITBOX") + local hitbox = character:FindFirstChild("_HITBOX") :: typeof(Managers.CharacterManager._HITBOX)? if not hitbox then return parts end @@ -76,7 +78,7 @@ function Character.getHitbox(mode: HitboxModes, params: OverlapParams?): { BaseP if mode == "WholeBody" then _addToListAndFilter(characterPart, parts, params) - elseif mode == "Center" and (characterPart.Name ~= "Left Arm" and characterPart.Name ~= "Right Arm") then + elseif (mode :: string) == "Center" and (characterPart.Name ~= "Left Arm" and characterPart.Name ~= "Right Arm") then _addToListAndFilter(characterPart, parts, params) end end @@ -114,7 +116,7 @@ end See [CharacterManager](/api/CharacterManager#GetHumanoid) for more info. ]=] function Character.getHumanoid(): Humanoid? - return CharacterManager:GetHumanoid(Players.LocalPlayer) + return CharacterManager:GetHumanoid(localPlayer) end --[=[ @@ -196,12 +198,16 @@ local weldedShoulders: { Motor6D } = {} the carry animation will stop. ]=] function Character.carryPart(weldState: boolean, weldTo: BasePart, animationDisabled: boolean) - local character = Players.LocalPlayer.Character + local character = localPlayer.Character + if not character then + return + end + local humanoid = character and character:FindFirstChildOfClass("Humanoid") if not humanoid then return end - + if weldState then local rootPart = humanoid.RootPart if not rootPart or not weldTo then @@ -219,7 +225,7 @@ function Character.carryPart(weldState: boolean, weldTo: BasePart, animationDisa rootWeld.Part1 = weldTo rootWelds[weldTo] = rootWeld - for index, arm in { character:FindFirstChild("Left Arm"), character:FindFirstChild("Right Arm") } do + for index, arm: BasePart in { character:FindFirstChild("Left Arm"), character:FindFirstChild("Right Arm") } do local shoulder = character:FindFirstChild(`{arm.Name:split(" ")[1]} Shoulder`, true) if not shoulder or not shoulder:IsA("Motor6D") then continue @@ -269,7 +275,6 @@ function Character.carryPart(weldState: boolean, weldTo: BasePart, animationDisa end end -local localPlayer = Players.LocalPlayer local characterParts = {} local function getParts(character: Model) task.defer(function() diff --git a/Kit/Utility/ClientObjects.luau b/Kit/Utility/ClientObjects.luau index 13da5b6..57f5d1a 100644 --- a/Kit/Utility/ClientObjects.luau +++ b/Kit/Utility/ClientObjects.luau @@ -235,22 +235,30 @@ function ClientObjects.formatTimerText(text: string, decimalPlaces: number, time local seconds = flooredSeconds % 60 local milliseconds = math.floor(timeRemaining * 100) % 100 - local playerName = localPlayer.Name - local playerDisplayName = localPlayer.DisplayName - - return text:gsub("{T}", displayTime) - :gsub("{M}", tostring(minutes)) - :gsub("{SM}", if tostring(minutes) == "1" then "" else "s") - :gsub("{S}", string.format("%02i", seconds)) - :gsub("{MS}", string.format("%02i", milliseconds)) - :gsub("{SS}", if displayTime == "1" then "" else "s") - :gsub("{pn}", playerName:lower()) - :gsub("{Pn}", playerName) - :gsub("{PN}", playerName:upper()) - :gsub("{dn}", playerDisplayName:lower()) - :gsub("{Dn}", playerDisplayName) - :gsub("{DN}", playerDisplayName:upper()) - :gsub("{UID}", localPlayer.UserId) + local playerName = "Player" + local playerDisplayName = "Player" + local uid = math.nan + if localPlayer then + playerName = localPlayer.Name + playerDisplayName = localPlayer.DisplayName + uid = localPlayer.UserId + end + + return (string.gsub(text, "{%w+}", { + ["{T}"] = displayTime, + ["{M}"] = tostring(minutes), + ["{SM}"] = if tostring(minutes) == "1" then "" else "s", + ["{S}"] = string.format("%02i", seconds), + ["{MS}"] = string.format("%02i", milliseconds), + ["{SS}"] = if displayTime == "1" then "" else "s", + ["{pn}"] = playerName:lower(), + ["{Pn}"] = playerName, + ["{PN}"] = playerName:upper(), + ["{dn}"] = playerDisplayName:lower(), + ["{Dn}"] = playerDisplayName, + ["{DN}"] = playerDisplayName:upper(), + ["{UID}"] = tostring(uid), + })) end --[=[ diff --git a/Kit/Utility/Config/Type.luau b/Kit/Utility/Config/Type.luau index ac841f9..d577cea 100644 --- a/Kit/Utility/Config/Type.luau +++ b/Kit/Utility/Config/Type.luau @@ -36,24 +36,7 @@ Type.Some = function(...): any? end Type.Enum = function(enum: T & EnumItem): T - return { - type = "EnumItem", - ignoreType = true, - check = function(value: EnumItem): (boolean, string?) - local valueType = typeof(value) - local check = valueType == "EnumItem" and value.EnumType == enum.EnumType - if not check then - return check, - `Enum.{enum.EnumType} expected, got {if valueType == "EnumItem" - then `Enum.{value.EnumType}` - else valueType}` - end - return check - end, - checkFailedProcessor = function() - return enum - end, - } :: any + return enum end Type.integer = ( diff --git a/Kit/Utility/Config/init.luau b/Kit/Utility/Config/init.luau index d17b34d..31bf2ba 100644 --- a/Kit/Utility/Config/init.luau +++ b/Kit/Utility/Config/init.luau @@ -105,6 +105,8 @@ local function processValue(value: any, default: any): (any, boolean?) return thisValue elseif typeof(value) ~= typeof(default) then return default + elseif typeof(value) == "EnumItem" and typeof(default) == "EnumItem" and value.EnumType ~= default.EnumType then + return default end return value diff --git a/Kit/Utility/Functions.luau b/Kit/Utility/Functions.luau index 6fe4754..c9f3b8e 100644 --- a/Kit/Utility/Functions.luau +++ b/Kit/Utility/Functions.luau @@ -39,7 +39,7 @@ local Config = require(script.Parent.Config) ``` ]=] function Functions.generateUID(curlyBraces: boolean?): string - return HttpService:GenerateGUID(curlyBraces or false):gsub("-", "") + return (HttpService:GenerateGUID(curlyBraces or false):gsub("-", "")) end --[=[ @@ -129,7 +129,7 @@ function Functions.playSoundFromInstance( return newSound end - return + return nil end --[=[