ภาค 2 · สร้างเกมกับผู้ช่วย AI
ผู้ช่วย AI 2: โลกกว้างและมอนสเตอร์
ใช้ prompt ทีละขั้นให้ AI สร้างโลก Terrain โมเดลมอนสเตอร์ใน ServerStorage และสคริปต์เกิดมอนสเตอร์ แล้วอ่านสคริปต์ หาเลข 10 สองตัวที่ความหมายต่างกัน และเปลี่ยนเองทีละตัว
เริ่มสร้างเกม RPG ⚔️ กับผู้ช่วย AI! วันนี้: โลกกว้าง 🌳 และ มอนสเตอร์ 👾 ที่เกิดเองไม่หยุด ส่ง prompt ทีละใบ กด Play ทุกครั้ง
ขั้น 1: โลกกว้าง 🌳
Generate open world terrain about 500 x 500 studs. Include grassy plains in the center, a forest area on the east side, a small lake, and hills around the edges. Add a flat spawn area in the middle with a SpawnLocation. Build the trees from Parts. Do not insert anything from the Creator Store.
กด Play เดินดูรอบ ๆ 🚶
- ☐ มีพื้นหญ้า ป่า ทะเลสาบ และเนิน
- ☐ เกิดตรงกลางบนพื้นเรียบ
AI สร้าง Terrain ไม่ได้? ไม่เป็นไร ✅ สร้างเองด้วยเครื่องมือ Terrain จากบทที่ 8 แล้วไปขั้น 2 ต่อ
ขั้น 2: โมเดลมอนสเตอร์ 👾
Create a simple monster model named "Monster" using Parts (a body, a head, and two eyes). Give it a Humanoid with 50 MaxHealth and a HumanoidRootPart. Put a BillboardGui above its head that shows its health, with a script that updates it when the health changes. Store the model in ServerStorage. Do not insert anything from the Creator Store.
ดูใน Explorer ☐ ServerStorage → Monster → มี Humanoid และ HumanoidRootPart
ServerStorage คืออะไร? 📦
ServerStorage คือ ห้องเก็บของหลังร้าน 🏪
ของในนี้ ไม่อยู่ในโลกของเกม ผู้เล่นมองไม่เห็น
สคริปต์จะ ทำสำเนา (:Clone()) ออกมาวางในโลกทีละตัว เหมือนปั๊มขนม 🍪
กด Play ตอนนี้ ยังไม่เห็นมอนสเตอร์ ถูกแล้ว! เพราะยังอยู่หลังร้าน
ขั้น 3: ตัวเกิดมอนสเตอร์ 🔁
Write a server Script named "MonsterSpawner" in ServerScriptService that spawns copies of "Monster" from ServerStorage at random positions within 150 studs of the SpawnLocation. Keep up to 10 monsters in the world at once. When a monster dies, remove it after 3 seconds and spawn a new one after 10 seconds. Do not insert anything from the Creator Store.
กด Play 🎮
- ☐ มีมอนสเตอร์หลายตัวยืนอยู่บนพื้น
- ☐ แต่ละตัวมีหลอดเลือดบนหัว
อ่านสคริปต์: เลข 10 สองตัว 🔍
- ดับเบิลคลิก
MonsterSpawnerใน ServerScriptService - กด Ctrl + F พิมพ์
10แล้วกด Enter
เราขอเลข 10 ไว้ 2 ที่ 🤔
- จำนวนมอนสเตอร์ สูงสุด 10 ตัว
- เวลารอเกิดใหม่ 10 วินาที
อ่านบรรทัดที่เจอ แล้วตอบให้ได้ว่า 10 ตัวไหน คือ อะไร
ใบ้: ดูชื่อตัวแปรรอบ ๆ เช่น MAX_MONSTERS หรือ task.wait(10)
- เปลี่ยน จำนวนสูงสุด เป็น
5ทายก่อน ว่าจะมีกี่ตัว แล้วกด Play นับใน Explorer → Workspace (โลกกว้าง มองไม่เห็นครบทุกตัว) ✅ - เขียนลงสมุด: เปลี่ยนอะไร ทายว่าอะไร เกิดอะไรจริง ✏️
ติดตรงไหน? เช็กตามลำดับ
- กด Play แล้วไม่มีมอนสเตอร์เลย →
Monsterอยู่ใน ServerStorage ไหม? สะกดตรงกับที่สคริปต์เรียกไหม? - มอนสเตอร์ตกทะลุพื้น หรือลอยฟ้า → บอก AI: “The monsters spawn inside the ground. Spawn them on top of the terrain.”
- มอนสเตอร์ล้มกลิ้ง → บอก AI: “The monster falls over. Make it stay upright.”
- มีข้อความสีแดง → คัดลอกไปบอก AI: “Fix this error: …”
แบบทดสอบ
ServerStorage คืออะไร? 📦
สคริปต์ทำสำเนามอนสเตอร์ด้วยคำสั่งไหน? 🍪
ทำไมต้อง ทายผลก่อน กด Play? 🤔
ส่ง prompt 3 ใบในบทนี้อย่างไรดีที่สุด?