How I can create variable what I can Connect like RBXConnection? (Without functions)
Creating an RBXConnection
-like object without directly using functions is a bit unconventional. I’m not sure if what you are describing is exactly possible, since events are usually linked to a function to run some sort of code.
Um yeah this sounds like a thing you wouldnt need what so ever, so like can you show a use case for this? That would help give us an understanding of what you want more
1 Like
I creating a module for my game:
(
local Camera = {}
Camera.__index = Camera
local Types =
{
"GameConnection";
"ApproximateConnection"
}
function Camera.Connections (Camera,Character)
local HRP = Character.HumanoidRootPart
local self = setmetatable({},Camera)
self.Camera = Camera
self.Character = Character
self.HRP = HRP
return self
end
function Camera:_GameConnection()
local GameConnection = game:GetService("RunService").RenderStepped:Connect(function()
self.Camera.CFrame = self.Camera.CFrame:Lerp(CFrame.new(self.HRP.Position + Vector3.new(0, 0, 22), self.HRP.Position), 0.1)
end)
function GameConnection:Disconnect()
GameConnection:Disconnect()
end
end
function Camera:_ApproximateConnection ()
local ApproximateConnection = game:GetService("RunService").RenderStepped:Connect(function()
self.Camera.CFrame = self.Camera.CFrame:Lerp(CFrame.new(self.HRP.Position + Vector3.new(0, 0, 16), self.HRP.Position), 0.1)
end)
function ApproximateConnection:Disconnect()
ApproximateConnection:Disconnect()
end
end
function Camera:Connect(Type: string)
self.Camera.CameraType = Enum.CameraType.Scriptable
if Type == Types[1] then
-- connect GameConnection
Camera:_GameConnection()
elseif Type == Types[2] then
--connect _ApproximateConnection Disconnect All other Connections
Camera:_GameConnection():Disconnect()
Camera:_ApproximateConnection()
end
end
return Camera
the parts of function Camera:_GameConnection(),function Camera:_ApproximateConnection()
probably don’t work (I haven’t checked yet, but I’m almost sure of it), but with them you can understand what I wanted to do