Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What is self and how can I use this thing called self?

On the devforum, I see that programs typically use something like this:

function CameraModule:LockMouse()
	if self.activeCameraController then
		local mouseLockOffset = self.activeMouseLockController:GetMouseLockOffset()
		self.activeCameraController:SetIsMouseLocked(true)
		self.activeCameraController:SetMouseLockOffset(mouseLockOffset*3)
	end
 end
--This is just an example of someone using the 'self' thing.

If you see this, there is a thing called self. What is self, and what are the practical uses of using self in functions like this? Any help is appreciated!

1 comment

0

Search Results Featured snippet from the web Now to answer your question, we use self as a way to access the previous argument called in the function, without passing the argument explicitly. self is notably used in Object Oriented Programming Implementation in Lua.

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.