Giant refactoring of how the client and server character is handled

This commit is contained in:
2024-04-19 23:08:02 -04:00
parent dbda8f9ca6
commit 4baf7bff51
15 changed files with 271 additions and 213 deletions

View File

@@ -1,113 +0,0 @@
--!optimize 2
--!native
--!strict
type CharacterSharedFolder = Folder
type TCP = RemoteEvent
local Dir = script.Parent
local Character = Dir.Parent
local CharacterShared = Dir:WaitForChild("shared")
local preprocessor = {}
function preprocessor.CharacterShared(): CharacterSharedFolder
return CharacterShared
end
_G.include = function(this: LuaSourceContainer, FunName: string, ...)
if this:IsDescendantOf(script) then --getfenv is being removed
local switch = preprocessor[FunName]
return type(switch) == "function" and switch(...) or switch
else
warn(`Preprocessor append failed "{FunName}"`, debug.traceback())
return nil
end
end
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
local RS: RunService = game:GetService("RunService")
local ClientStorage: Instance = Storage:WaitForChild("Client") :: Folder
local LoadCompleted: Instance = ClientStorage:WaitForChild("LoadingComplete") :: BindableFunction
local ActionsTCP: TCP = CharacterShared:WaitForChild("Actions")
--We need to wait for the game to load before spamming functionality
repeat
local GameIsLoaded = (LoadCompleted :: BindableFunction):Invoke()
task.wait()
until GameIsLoaded
local HumanoidRPSettings = require(script:WaitForChild("HumanoidRootPart"))
local CameraModule = require(script:WaitForChild("Camera"))
local HumanoidModule = require(script:WaitForChild("Humanoid"))
local SpineModule = require(script:WaitForChild("SpineKinematics"))
local ActionsModule = require(script:WaitForChild("Actions"))
local BindModule = require(ClientStorage:WaitForChild("KeyBinds"))
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Humanoid = Character:WaitForChild("Humanoid")
local CurrentCamera = workspace.CurrentCamera
local HRPSettings = HumanoidRPSettings.constructor(HumanoidRootPart)
local CameraConsturctor = CameraModule.constructor(CurrentCamera, HumanoidRootPart, Humanoid)
local HumanoidSettings = HumanoidModule.constructor(Humanoid)
local SpineMovement = SpineModule.constructor(CurrentCamera)
local ClientBindMap = BindModule.constructor(false)
local function ClientCharacterBinds()
local Actions = ActionsModule.constructor(HumanoidSettings, CurrentCamera, ActionsTCP)
--Crouch
ClientBindMap:AddInputBegan({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function(_KeyPressed)
Actions:EnableCrouch()
end)
ClientBindMap:AddInputEnded({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function(_KeyPressed)
Actions:DisableCrouch()
end)
--Walk
ClientBindMap:AddInputBegan({
Enum.KeyCode.LeftAlt,
Enum.KeyCode.RightAlt,
Enum.KeyCode.LeftShift,
Enum.KeyCode.RightShift
}, function(_KeyPressed)
Actions:EnableSneak()
end)
ClientBindMap:AddInputEnded({
Enum.KeyCode.LeftAlt,
Enum.KeyCode.RightAlt,
Enum.KeyCode.LeftShift,
Enum.KeyCode.RightShift
}, function(_KeyPressed)
Actions:DisableSneak()
end)
--Flashlight
ClientBindMap:AddInputBegan({Enum.KeyCode.F}, function(KeyPressed: Enum.KeyCode)
Actions:ToggleFlashlight(KeyPressed)
end)
end
--Needs to be a module maybe
local function Crosshair3DVelocity_Effect(): RBXScriptConnection
local RootVelocity = ClientStorage:WaitForChild("RootVelocity") :: BindableEvent
local RootVelocityStep = RS.Heartbeat:ConnectParallel(function(_dt)
RootVelocity:Fire(HRPSettings:Velocity())
end)
return RootVelocityStep
end
HumanoidSettings:SetWalkSpeed()
HumanoidSettings:SetJumpHeight()
HRPSettings:DisableRobloxSounds()
CameraConsturctor:EnableBobbing()
--SpineMovement:Enable()
ClientCharacterBinds()
Crosshair3DVelocity_Effect()
_G.include = nil

View File

@@ -3,21 +3,26 @@
--!strict
type UDP = UnreliableRemoteEvent
local Dir = script.Parent
local Character = Dir.Parent
local preprocessor = {}
local FlashlightCooldown = .10
type CharacterSharedFolder = Folder
local Players = game:GetService("Players")
--Create the character shared directory here
local CharacterShared = Instance.new("Folder")
CharacterShared.Name = "shared"
CharacterShared.Parent = Dir
local Dir = script.Parent
local Character = Dir.Parent
local preprocessor = {}
--Production--
--if not RS:IsStudio() then
task.wait()
Dir.Parent = nil
--end
--
--Create the character shared directory here
local CharacterShared = Instance.new("Folder")
CharacterShared.Name = "shared"
CharacterShared.Parent = Character
type CharacterSharedFolder = Folder
function preprocessor.CharacterShared(): Instance
return CharacterShared :: CharacterSharedFolder
end
@@ -58,6 +63,8 @@ Character.DescendantAdded:Connect(function(Instance)
CharacterShadows:PartToggle(Instance, false)
end)
local FlashlightCooldown = .10
Actions:Add(Enum.KeyCode.F, function(_KeyPressed)
if not FlashlightDebounce then
Flashlight:Toggle()

View File

@@ -0,0 +1,125 @@
--!optimize 2
--!native
--!strict
type CharacterSharedFolder = Folder
type TCP = RemoteEvent
local CharacterModule = {}
CharacterModule.__index = CharacterModule
local RS = game:GetService("RunService")
local Storage = game:GetService("ReplicatedStorage")
local ClientStorage = Storage:WaitForChild("Client") :: Folder
local preprocessor = {}
local CharacterShared: Folder
function preprocessor.CharacterShared(): CharacterSharedFolder
return CharacterShared
end
_G.include = function(this: LuaSourceContainer, FunName: string, ...)
if this:IsDescendantOf(script) then --getfenv is being removed
local switch = preprocessor[FunName]
return type(switch) == "function" and switch(...) or switch
else
warn(`Preprocessor append failed "{FunName}"`, debug.traceback())
return nil
end
end
function CharacterModule.constructor(Character)
CharacterShared = Character:WaitForChild("shared")
local HumanoidRPSettings = require(script:WaitForChild("HumanoidRootPart"))
local CameraModule = require(script:WaitForChild("Camera"))
local HumanoidModule = require(script:WaitForChild("Humanoid"))
local SpineModule = require(script:WaitForChild("SpineKinematics"))
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Humanoid = Character:WaitForChild("Humanoid")
local self = {}
self.ActionsTCP = CharacterShared:WaitForChild("Actions")
self.ActionsModule = require(script:WaitForChild("Actions"))
self.BindModule = require(ClientStorage:WaitForChild("KeyBinds"))
self.CurrentCamera = workspace.CurrentCamera
self.HRPSettings = HumanoidRPSettings.constructor(HumanoidRootPart)
self.CameraConsturctor = CameraModule.constructor(self.CurrentCamera, HumanoidRootPart, Humanoid)
self.HumanoidSettings = HumanoidModule.constructor(Humanoid)
self.SpineMovement = SpineModule.constructor(self.CurrentCamera)
return setmetatable(self, CharacterModule)
end
function CharacterModule:CharacterKeyBinds()
local ClientBindMap = self.BindModule.constructor(false)
local Actions = self.ActionsModule.constructor(self.HumanoidSettings, self.CurrentCamera, self.ActionsTCP)
--Crouch
ClientBindMap:AddInputBegan({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function(_KeyPressed)
Actions:EnableCrouch()
end)
ClientBindMap:AddInputEnded({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function(_KeyPressed)
Actions:DisableCrouch()
end)
--Walk
ClientBindMap:AddInputBegan({
Enum.KeyCode.LeftAlt,
Enum.KeyCode.RightAlt,
Enum.KeyCode.LeftShift,
Enum.KeyCode.RightShift
}, function(_KeyPressed)
Actions:EnableSneak()
end)
ClientBindMap:AddInputEnded({
Enum.KeyCode.LeftAlt,
Enum.KeyCode.RightAlt,
Enum.KeyCode.LeftShift,
Enum.KeyCode.RightShift
}, function(_KeyPressed)
Actions:DisableSneak()
end)
--Flashlight
ClientBindMap:AddInputBegan({Enum.KeyCode.F}, function(KeyPressed: Enum.KeyCode)
Actions:ToggleFlashlight(KeyPressed)
end)
end
function CharacterModule:Crosshair()
local RootVelocity = ClientStorage:WaitForChild("RootVelocity") :: BindableEvent
local RootVelocityStep = RS.Heartbeat:ConnectParallel(function(_dt)
RootVelocity:Fire(self.HRPSettings:Velocity())
end)
return RootVelocityStep
end
function CharacterModule:SetWalkSpeed()
self.HumanoidSettings:SetWalkSpeed()
end
function CharacterModule:SetJumpHeight()
self.HumanoidSettings:SetJumpHeight()
end
function CharacterModule:DisableRobloxSounds()
self.HRPSettings:DisableRobloxSounds()
end
function CharacterModule:EnableCameraBobbing()
self.CameraConsturctor:EnableBobbing()
end
function CharacterModule:EnableSpineMovement()
self.SpineMovement:Enable()
end
_G.include = nil
return CharacterModule

View File

@@ -2,40 +2,65 @@
--!native
--!strict
type CurrentCamera = Camera
local Players = game:GetService("Players")
local Storage = game:GetService("ReplicatedStorage")
local RS = game:GetService("RunService")
--Production--
--if not RS:IsStudio() then
RS.RenderStepped:Wait()
script.Parent.Parent = nil
--end
--
local UI = script:WaitForChild("UI")
local CrosshairSettings = require(UI:WaitForChild("Crosshair"))
local VignetteSettings = require(UI:WaitForChild("Vignette"))
local HealthSettings = require(UI:WaitForChild("Health"))
local CoreGuis = require(script:WaitForChild("CoreGuis"))
local Mouse = require(script:WaitForChild("Mouse"))
local Character = require(script:WaitForChild("Character"))
local Players: Players = game:GetService("Players")
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
local ClientStorage = Storage:WaitForChild("Client")
local LoadCompleted = ClientStorage:WaitForChild("LoadingComplete")
local KeyBindsModule = require(ClientStorage:WaitForChild("KeyBinds"))
local CameraSettings = require(ClientStorage:WaitForChild("Camera"))
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui") :: PlayerGui
local function LoadCharacter(CharacterModel)
local CharacterConstructor = Character.constructor(CharacterModel)
CharacterConstructor:DisableRobloxSounds()
CharacterConstructor:SetWalkSpeed()
CharacterConstructor:SetJumpHeight()
CharacterConstructor:Crosshair()
CharacterConstructor:EnableCameraBobbing()
CharacterConstructor:CharacterKeyBinds()
end
--We need to wait for the game to load before spamming functionality
repeat
local GameIsLoaded = (LoadCompleted :: BindableFunction):Invoke()
local GameIsLoaded = game:IsLoaded()
task.wait()
until GameIsLoaded
local CurrentCamera = nil
local CurrentCamera: CurrentCamera
repeat
task.wait()
CurrentCamera = workspace.CurrentCamera
until CurrentCamera
local ClientStorage = Storage:WaitForChild("Client")
local KeyBindsModule = require(ClientStorage:WaitForChild("KeyBinds"))
local CameraSettings = require(ClientStorage:WaitForChild("Camera"))
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui") :: PlayerGui
local PlayerCharacter = Player.Character or Player.CharacterAdded:Wait()
local Vignette = VignetteSettings.constructor(PlayerGui)
local Camera = CameraSettings.constructor(CurrentCamera, Player)
local Crosshair = CrosshairSettings.constructor(PlayerGui)
LoadCharacter(PlayerCharacter)
Player.CharacterAdded:Connect(LoadCharacter)
--Keybinds
local function CameraBinds()
local CameraBindMap = KeyBindsModule.constructor(false)

View File

@@ -30,6 +30,8 @@ type GuiDependencies = {
FrameworkText: TextLabel,
SandboxText: TextLabel,
DeveloperText: TextLabel,
Quaternions: ImageLabel,
TaylorSeries: ImageLabel,
Xframe: Frame,
Yframe: Frame,
Zframe: Frame,
@@ -41,6 +43,7 @@ type GuiDependencies = {
local RS = game:GetService("RunService")
local Storage = game:GetService("ReplicatedStorage")
local TS = game:GetService("TestService")
local CoP = game:GetService("ContentProvider")
local LoadingFun = true
@@ -55,6 +58,8 @@ local function GuiDependencies(IntroGui: ScreenGui): GuiDependencies
local SandboxText = Frame:WaitForChild("Sandbox") :: TextLabel
local DeveloperText = Frame:WaitForChild("Developer") :: TextLabel
local ShadowGradient = TextShadow:WaitForChild("UIGradient") :: UIGradient
local Quaternions = Frame:WaitForChild("Quaternions") :: ImageLabel
local TaylorSeries = Frame:WaitForChild("TaylorSeries") :: ImageLabel
local Xframe = Frame:WaitForChild("X") :: Frame
local Yframe = Frame:WaitForChild("Y") :: Frame
@@ -73,6 +78,8 @@ local function GuiDependencies(IntroGui: ScreenGui): GuiDependencies
FrameworkText = FrameworkText,
SandboxText = SandboxText,
DeveloperText = DeveloperText,
Quaternions = Quaternions,
TaylorSeries = TaylorSeries,
Xframe = Xframe,
Yframe = Yframe,
Zframe = Zframe,
@@ -82,6 +89,9 @@ local function GuiDependencies(IntroGui: ScreenGui): GuiDependencies
}
end
local Size = 300
local WorldSize = 3
local function GUI_LoadFinish(Stepped: Stepped, Gui: GuiDependencies) --We can now access the framework
--Image if we had HTML and CSS...
local Tween = require(Storage:WaitForChild("Tween"))
@@ -89,12 +99,28 @@ local function GUI_LoadFinish(Stepped: Stepped, Gui: GuiDependencies) --We can n
local FrameTween_Constructor = Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.Frame, {
BackgroundTransparency = 1
})
local DeveloperTween_Constructor = Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.DeveloperText, {
Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.DeveloperText, {
TextTransparency = 1
})
}):Start()
Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.TaylorSeries, {
ImageTransparency = 1
}):Start()
Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.Quaternions, {
ImageTransparency = 1
}):Start()
Tween.constructor(TweenInfo.new(.5, Enum.EasingStyle.Linear), Gui.Xframe_text, {
TextTransparency = 1
}):Start()
Tween.constructor(TweenInfo.new(.5, Enum.EasingStyle.Linear), Gui.Yframe_text, {
TextTransparency = 1
}):Start()
Tween.constructor(TweenInfo.new(.5, Enum.EasingStyle.Linear), Gui.Zframe_text, {
TextTransparency = 1
}):Start()
local FrameTween = FrameTween_Constructor:Start()
DeveloperTween_Constructor:Start()
--Text deleting effect
task.spawn(function()
@@ -108,9 +134,16 @@ local function GUI_LoadFinish(Stepped: Stepped, Gui: GuiDependencies) --We can n
end
end)
task.spawn(function()
while task.wait() do
Size = math.max(0, Size-5)
end
end)
FrameTween.Completed:Wait()
Stepped:Disconnect()
Gui.IntroGui:Destroy() --We dont need the intro gui anymore
script.Parent:Destroy()
end
local function RotationMatrix(X: number, Y: number, Z: number): RotationMatrix
@@ -132,61 +165,63 @@ local function Scalar(X1: number, Y1: number, X2: number, Y2: number): Scalar
}
end
local Size = 300
local WorldSize = 3
local function UI_3D_Rotation(Gui: GuiDependencies, Delta: number)
local ScreenD = workspace.CurrentCamera.ViewportSize
local CenterX = ScreenD.X/2
local CenterY = ScreenD.Y/1.4
local mX = Delta/1.5
local mY = Delta/1.5
local mZ = -7.65
local RMatrix = RotationMatrix(mX,mY,mZ)
local X = {Size*RMatrix.Ixx, Size*RMatrix.Ixy}
local Y = {Size*RMatrix.Iyx, Size*RMatrix.Iyy}
local Z = {Size*RMatrix.Izx, Size*RMatrix.Izy}
local AXIS_R_3DScalar_X = Scalar(CenterX+X[1],CenterY+X[2],CenterX,CenterY)
local AXIS_R_3DScalar_Y = Scalar(CenterX+Y[1],CenterY+Y[2],CenterX,CenterY)
local AXIS_R_3DScalar_Z = Scalar(CenterX+Z[1],CenterY+Z[2],CenterX,CenterY)
Gui.Xframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_X.Center.X, AXIS_R_3DScalar_X.Center.Y)
Gui.Yframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_Y.Center.X, AXIS_R_3DScalar_Y.Center.Y)
Gui.Zframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_Z.Center.X, AXIS_R_3DScalar_Z.Center.Y)
Gui.Xframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_X.Center.X, AXIS_R_3DScalar_X.Center.Y)
Gui.Yframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_Y.Center.X, AXIS_R_3DScalar_Y.Center.Y)
Gui.Zframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_Z.Center.X, AXIS_R_3DScalar_Z.Center.Y)
Gui.Xframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_X.Distance, WorldSize)
Gui.Yframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_Y.Distance, WorldSize)
Gui.Zframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_Z.Distance, WorldSize)
Gui.Xframe.Rotation = AXIS_R_3DScalar_X.Rotation
Gui.Yframe.Rotation = AXIS_R_3DScalar_Y.Rotation
Gui.Zframe.Rotation = AXIS_R_3DScalar_Z.Rotation
Gui.Xframe_text.Rotation = Gui.Xframe.Rotation
Gui.Yframe_text.Rotation = Gui.Yframe.Rotation
Gui.Zframe_text.Rotation = Gui.Zframe.Rotation
end
return function(IntroGui: ScreenGui, load_elapse_start: number)
local Gui = GuiDependencies(IntroGui)
local Stepped = RS.Stepped:Connect(function(Delta: number, dt: number)
local ScreenD = workspace.CurrentCamera.ViewportSize
local CenterX = ScreenD.X/2
local CenterY = ScreenD.Y/1.4
local mX = Delta/1.5
local mY = Delta/1.5
local mZ = -7.65
local RMatrix = RotationMatrix(mX,mY,mZ)
local X = {Size*RMatrix.Ixx, Size*RMatrix.Ixy}
local Y = {Size*RMatrix.Iyx, Size*RMatrix.Iyy}
local Z = {Size*RMatrix.Izx, Size*RMatrix.Izy}
local AXIS_R_3DScalar_X = Scalar(CenterX+X[1],CenterY+X[2],CenterX,CenterY)
local AXIS_R_3DScalar_Y = Scalar(CenterX+Y[1],CenterY+Y[2],CenterX,CenterY)
local AXIS_R_3DScalar_Z = Scalar(CenterX+Z[1],CenterY+Z[2],CenterX,CenterY)
Gui.Xframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_X.Distance, WorldSize)
Gui.Xframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_X.Center.X, AXIS_R_3DScalar_X.Center.Y)
Gui.Xframe.Rotation = AXIS_R_3DScalar_X.Rotation
Gui.Xframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_X.Center.X, AXIS_R_3DScalar_X.Center.Y)
Gui.Xframe_text.Rotation = Gui.Xframe.Rotation
Gui.Yframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_Y.Distance, WorldSize)
Gui.Yframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_Y.Center.X, AXIS_R_3DScalar_Y.Center.Y)
Gui.Yframe.Rotation = AXIS_R_3DScalar_Y.Rotation
Gui.Yframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_Y.Center.X, AXIS_R_3DScalar_Y.Center.Y)
Gui.Yframe_text.Rotation = Gui.Yframe.Rotation
Gui.Zframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_Z.Distance, WorldSize)
Gui.Zframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_Z.Center.X, AXIS_R_3DScalar_Z.Center.Y)
Gui.Zframe.Rotation = AXIS_R_3DScalar_Z.Rotation
Gui.Zframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_Z.Center.X, AXIS_R_3DScalar_Z.Center.Y)
Gui.Zframe_text.Rotation = Gui.Zframe.Rotation
local Stepped = RS.Stepped:Connect(function(Delta: number, _dt: number)
UI_3D_Rotation(Gui, Delta)
end)
task.spawn(function()
CoP:PreloadAsync({Gui.TaylorSeries, Gui.Quaternions}) --Try as early as possible
if not game:IsLoaded() then
game.Loaded:Wait()
end
local load_elapse = os.clock()-load_elapse_start
if LoadingFun then
task.wait(math.max(0, 3-load_elapse)) --Only if you take longer than or exactly 3 seconds to load
task.wait(math.max(0, 4-load_elapse)) --Only if you take longer than or exactly 4 seconds to load
end
TS:Message("Load elapse: "..tostring(load_elapse), game)
GUI_LoadFinish(Stepped, Gui)

View File

@@ -6,20 +6,10 @@ local load_elapse_start = os.clock()
local ReplicatedFirst = game:GetService("ReplicatedFirst")
local Players = game:GetService("Players")
local Storage = game:GetService("ReplicatedStorage")
local DisabledInStudio = false
local DisabledInStudio = game:GetService("RunService"):IsStudio()
local IntroGui = nil
local function LoadedBind()
local Bind_Completed = Instance.new("BindableFunction")
Bind_Completed.Name = "LoadingComplete"
Bind_Completed.Parent = Storage:WaitForChild("Client")
Bind_Completed.OnInvoke = function()
return game:IsLoaded()
end
end
local function LoadingIntroGUI()
ReplicatedFirst:RemoveDefaultLoadingScreen()
@@ -46,6 +36,6 @@ end
if not DisabledInStudio then
LoadingIntroGUI()
end
LoadedBind()
else
script:Destroy()
end

View File

@@ -61,9 +61,9 @@ export type LanternsTree = {
}
export type LightSwitchProperties = {
Switch: BasePart?,
Lights: {BasePart}?,
LightSources: {PointLight | SpotLight}?,
Switch: Instance?,
Lights: {Instance}?,
LightSources: {Instance}?,
Prompt: ProximityPrompt?,
ClickSound: Sound?,
ColorActivated: Color3?,
@@ -288,10 +288,10 @@ function Tags:__Interactables()
ptr.Lights = Inst
else
ptr.Lights = {}
table.insert(ptr.Lights :: {BasePart}, Inst :: BasePart)
table.insert(ptr.Lights :: {Instance}, Inst)
end
elseif InteractType == Enums.InteractType.LightSource then
ptr.LightSources = {}
ptr.LightSources = (type(Inst) == "table" and Inst or {Inst :: Instance}) :: {Instance}
end
end
end