ロブロックスでは、Lua(ルア)というプログラミング言語を使ってスクリプトの中に打ち込まれます。ライブラリテンプレートにはすでに StoryManager というスクリプトがあり、これにストーリーゲーム用のコードを追加していくことになります。
StoryManager を見つける
- エクスプローラウィンドウで、StarterGUI の横にある矢印をクリックして、その下のすべてを表示します。

- GameGUI の横にある矢印をクリックして、そのセクションを展開します。

- StoryManager スクリプトをダブルクリックして開きます。

スクリプトの内容
スクリプトには、完成した物語をプレイヤーに見せるために必要なコードの一部がすでに含まれています。これから作成するコードは、すべて破線の下に入力されます。
とりあえず、スクリプトの大部分が「–」という記号で始まっていることに注目してください。「–」で始まる行はコメントと呼ばれます。これはプログラマーのためのメモとして使われるもので、プログラム自体に影響を及ぼすものではありません。
-- GLOBAL VARIABLES
local storyMaker = require(script:WaitForChild("StoryMaker"))
-- Code controlling the game
local playing = true
while playing do
storyMaker:Reset()
-- Code story between the dashes
-- =============================================
-- =============================================
-- Add the story variable between the parenthesis below
storyMaker:Write()
-- Play again?
playing = storyMaker:PlayAgain()
end
[ S-5 質問のコーディング ]