Creator Guide
Korean
Korean
  • OVERDARE
    • 🚩OVERDARE 소개
    • 🐤시작하기
      • OVERDARE App
      • OVERDARE Studio
    • 📌운영 정책
      • 커뮤니티 가이드라인
      • UGC 콘텐츠 제작 가이드라인
      • UGC의 외부 활용 가이드라인
      • LOGO 활용 가이드라인
      • 지식 재산권 정책
      • 신고 안내
      • 콘텐츠 제재 이의 신청 안내
      • 크리에이터 정산 정책
      • OVERDARE 수익화 가이드라인
    • 🅰️OVERDARE Glossary
  • MANUAL
    • 🏰스튜디오 메뉴얼
      • 시작하기
        • 스튜디오 인터페이스
        • 월드 템플릿
        • 좌표계
        • 스튜디오 테스트 플레이
        • 월드 퍼블리시
        • Collaboration
      • 에셋 & 리소스 제작
        • 에셋 임포트
        • 애니메이션 에디터
      • 게임 제작
        • 게임 설정
        • 스크립트 에디터
        • 정렬
        • Material Manager
        • Collision Groups
        • Tag Editor
        • 퍼포먼스 가이드
      • Object
        • 파트
        • 모델
        • 카메라
        • 물리
        • 조명
        • Tool
        • VFX
        • Sound
      • 캐릭터
        • 캐릭터 애니메이션
        • Humanoid Description
      • GUI
    • 📝스크립트 메뉴얼
      • 시작하기
        • 스크립트 개요
        • 루아 기초 가이드
        • 코딩 스타일
        • 오브젝트 참조
        • 유니티 개발자용 가이드
      • 이벤트 및 통신
        • 이벤트
        • 서버-클라 통신
        • BindableEvent
        • Value Objects
      • 입력 및 조작
        • 모바일 조작 처리
        • TPS Strafing System
      • 게임 고도화
        • Saving & Loading Data
        • 트윈
        • 모듈 스크립트
      • 디버깅 & 최적화
        • 중단점
        • 스크립트 최적화 실전 가이드
  • 💸수익화
    • Payout Guideline
  • DEVELOPMENT
    • 📚API Reference
      • Enums
        • ActuatorRelativeTo
        • AnimationPriority
        • AspectType
        • AssetTypeVerification
        • BorderMode
        • CameraMode
        • CameraType
        • ContextActionResult
        • CoreGuiType
        • DominantAxis
        • EasingDirection
        • EasingStyle
        • ForceLimitMode
        • HttpCompression
        • HttpContentType
        • HumanoidDisplayDistanceType
        • HumanoidStateType
        • KeyCode
        • Material
        • MaterialPattern
        • NormalId
        • ParticleEmitterShape
        • ParticleEmitterShapeInOut
        • ParticleEmitterShapeStyle
        • ParticleFlipbookLayout
        • ParticleFlipbookMode
        • ParticleOrientation
        • PartType
        • PlaybackState
        • RaycastFilterType
        • RollOffMode
        • RotationType
        • UserInputState
        • UserInputType
        • VelocityConstraintMode
      • DataTypes
        • BlendSpaceSampleSata
        • BrickColor
        • CFrame
        • Color3
        • ColorSequence
        • ColorSequenceKeypoint
        • Content
        • Enum
        • EnumItem
        • NumberRange
        • NumberSequence
        • NumberSequenceKeypoint
        • OverlapParams
        • PhysicalProperties
        • Ray
        • RaycastParams
        • RaycastResult
        • ScriptConnection
        • ScriptSignal
        • TweenInfo
        • Udim
        • Udim2
        • Vector2
        • Vector3
      • Classes
        • Animation
        • AngularVelocity
        • AnimationTrack
        • Animator
        • Atmosphere
        • Attachment
        • Backpack
        • BackpackItem
        • BasePart
        • BaseScript
        • Beam
        • BindableEvent
        • BlendSpace
        • BoolValue
        • Bone
        • Camera
        • CharacterMesh
        • CollectionService
        • Constraint
        • ContextActionService
        • CoreGui
        • DataStore
        • DataModel
        • DataStoreGetOptions
        • DataStoreIncrementOptions
        • DataStoreInfo
        • DataStoreKeyPages
        • DataStoreKeyInfo
        • DataStoreService
        • DataStoreListingPages
        • DataStoreSetOptions
        • FormFactorPart
        • Frame
        • Folder
        • GlobalDataStore
        • GuiBase2d
        • GuiButton
        • GuiObject
        • HttpService
        • Humanoid
        • HumanoidDescription
        • ImageButton
        • ImageLabel
        • InputObject
        • IntValue
        • LayerCollector
        • Instance
        • Light
        • Lighting
        • LinearVelocity
        • LocalScript
        • LuaSourceContainer
        • MaterialService
        • MaterialVariant
        • MeshPart
        • Model
        • ModuleScript
        • Mouse
        • OrderedDataStore
        • Pages
        • Part
        • ParticleEmitter
        • PhysicsService
        • Player
        • PlayerGui
        • Players
        • PlayerScripts
        • PointLight
        • PVInstance
        • ReplicatedStorage
        • RemoteEvent
        • ScreenGui
        • RunService
        • Script
        • ServerStorage
        • ServiceProvider
        • Skeleton
        • ServerScriptService
        • Sound
        • SoundService
        • SoundGroup
        • SpotLight
        • SpawnLocation
        • StarterCharacterScripts
        • StarterPack
        • StarterGui
        • StarterPlayer
        • StarterPlayerScripts
        • StringValue
        • SurfaceGui
        • SurfaceGuiBase
        • Team
        • Teams
        • TextLabel
        • TextButton
        • Tool
        • Trail
        • Tween
        • TweenService
        • TweenBase
        • UIAspectRatioConstraint
        • UserGameSettings
        • UserInputService
        • UserSettings
        • VectorForce
        • Workspace
        • WrapLayer
        • WorldRoot
        • WrapTarget
  • UPDATE
    • 📰Release Note
Powered by GitBook
On this page
  • 개요
  • 권장 실행 위치
  • 동작 원리
  • 1. 모듈 스크립트 구현
  • 2. 모듈 스크립트 참조 & 사용
  • 모듈 스크립트 응용
  • 유틸리티 클래스
  • 데이터 클래스
  • 클래스 상속
  1. MANUAL
  2. 스크립트 메뉴얼
  3. 게임 고도화

모듈 스크립트

개요

모듈 스크립트(ModuleScript)는 공통된 기능을 분리하여 재사용 가능하도록 구조화하기 위해 사용되는 스크립트입니다. 이를 통해 코드의 중복을 줄이고, 유지보수를 효율적으로 수행할 수 있습니다.

권장 실행 위치

  • 서버와 클라이언트에서 모두 사용해야 하는 모듈 스크립트는 ReplicatedStorage에 배치하는 것이 일반적입니다. (예 : Script와 LocalScript에서 VectorUtil 모듈 참조)

  • 서버에서만 사용하는 모듈 스크립트는 보안과 관리 측면에서 ServerScriptService 에 배치하는 것이 권장됩니다. (예 : Script에서 ServerGameConstValue 모듈 참조)

  • 클라이언트에서만 사용하는 모듈 스크립트는 용도에 따라 StarterPlayerScripts나 StarterCharacterScripts에 배치하는 것이 권장됩니다. (예 : LocalScript에서 Gui 모듈 참조)

동작 원리

모듈은 명시적으로 호출(require)될 때 실행되며, 첫 호출 시 초기화된 결과가 캐싱되므로 이후 호출 시에는 동일한 값을 반환합니다. 이를 통해 실행 효율을 높이고, 일관성을 유지할 수 있습니다.

1. 모듈 스크립트 구현

local UtilityModule = {}

function UtilityModule.PrintMessage(message)
    print("PrintMessage : " .. message)
end

return UtilityModule

2. 모듈 스크립트 참조 & 사용

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UtilityModule = require(ReplicatedStorage.UtilityModule)

UtilityModule:PrintMessage("Hello World!")

모듈 스크립트 응용

유틸리티 클래스

ModuleScript에서

local MathUtil = {}

-- Example Function 1
function MathUtil:Sum(...)
    local numList = { ... }
    local result = 0
    
    for i = 1, #numList do
        result = result + numList[i]
    end
    
    return result 
end

-- Example Function 2
function MathUtil:SomeFunc()
    print("SomeFunc")
end

return MathUtil

Script 또는 LocalScript에서

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MathUtil = require(ReplicatedStorage.MathUtil)

local sum = MathUtil:Sum(1, 5, 9, 10)
print(sum)

데이터 클래스

ModuleScript에서

local GameConstValue = {}

GameConstValue.RequirePlayerCount = 10
GameConstValue.MaxRound = 5
GameConstValue.RoundLimitTime = 180

return GameConstValue 

Script 또는 LocalScript에서

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GameConstValue = require(ReplicatedStorage.GameConstValue)

local function CheckPlayerCount(playerCount)
    if playerCount >= GameConstValue.RequirePlayerCount then
        print("Ready to start the game")
    end
end

클래스 상속

ModuleScript에서

local MonsterClass = {}
MonsterClass.__index = MonsterClass

function MonsterClass:new(name, hp, dam, def)
    local self = setmetatable({}, MonsterClass)
    self._Name = name
    self._Hp = hp
    self._MaxHp = hp
    self._Dam = dam
    self._Def = def
    
    return self
end

function MonsterClass:Attack()
    print(self._Name, "Attack!")
end

function MonsterClass:Move()
    print(self._Name, "Move!")
end

function MonsterClass:Destroy()
    print(self._Name, "Destroy!")
end

return MonsterClass

Script 또는 LocalScript에서

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MonsterClass = require(ReplicatedStorage.MonsterClass)

local Goblin = MonsterClass:new("Goblin", 100, 10, 5)
local Orc = MonsterClass:new("Orc", 200, 10, 5)

print(Goblin._Name)
print(Orc._Name)

Goblin:Attack()
Orc:Attack()
Previous트윈Next디버깅 & 최적화

Last updated 2 months ago

📝