Roblox Studioで Toolbox からタワーディフェンスキット(Tower Defense Kit)を動かしたいと考えました。
きっとはすぐ配置できるのですが、配置しただけでは正しく動作しない場合があります。
このような場合は README を読むのが大事です。
エクスプローラー上の各フォルダ・スクリプトを適切な場所へ配置し換える必要があるようでした。
概要
配布キットは、全アセットが1つのモデル内にまとまって配置されているようです。
これをRobloxの推奨するディレクトリ構造(ReplicatedStorage や ServerScriptService など)へ移動させることで動作する仕組みになっています。
配置手順
キットが配置された後、以下の通りエクスプローラー(Explorer)内でドラッグ&ドロップして配置を変更するように指示がありました。
-- Move Grassland to Workspace
-- Move Info to Workspace
-- Move Mobs(The Empty one, nothing inside) to Workspace
-- Move Towers(The Empty one, nothing inside) to Workspace
-- Move Events to ReplicatedStorage
-- Move Functions to ReplicatedStorage
-- Move Modules to ReplicatedStorage
-- Move Towers(with models inside) to ReplicatedStorage
-- Move Main to ServerScriptService
-- Move OnPlayerAdded to ServerScriptService
-- Move Archimedes_Storage to ServerStorage
-- Move Bindables to ServerStorage
-- Move Mobs(with models inside) to ServerStorage
-- Move Tower to ServerStorage
-- Move Billboards to StarterGui
-- Move GameGui to StarterGui
-- Move Animations to StarterPlayerScripts
-- Move Start to Workspace
-- Move StartPart to Workspace(Place the Start to your Lobby)
-- Move End to Workspace(Place the End inside the Playing Area)
要はそれぞれディレクトリに役割があるのか、機能を移動する必要があるようです。
これ手動でやるの?って思ったら、AI が lua でできるよとコードを出力してくれました。
local kit = workspace:FindFirstChild("Tower Defense Kit")
if kit then
local moves = {
Grassland = workspace,
Info = workspace,
Start = workspace,
StartPart = workspace,
End = workspace,
Events = game:GetService("ReplicatedStorage"),
Functions = game:GetService("ReplicatedStorage"),
Modules = game:GetService("ReplicatedStorage"),
Main = game:GetService("ServerScriptService"),
OnPlayerAdded = game:GetService("ServerScriptService"),
Archimedes_Storage = game:GetService("ServerStorage"),
Bindables = game:GetService("ServerStorage"),
Tower = game:GetService("ServerStorage"),
Billboards = game:GetService("StarterGui"),
GameGui = game:GetService("StarterGui"),
Animations = game:GetService("StarterPlayer"):FindFirstChild("StarterPlayerScripts")
}
for item, target in pairs(moves) do
local obj = kit:FindFirstChild(item)
if obj and target then
obj.Parent = target
end
end
for _, item in ipairs(kit:GetChildren()) do
if item.Name == "Mobs" or item.Name == "Towers" then
if #item:GetChildren() == 0 then
item.Parent = workspace
else
item.Parent = game:GetService("ReplicatedStorage")
end
end
end
print("自動配置が完了しました。")
end
なんてコードだ。
Roblox Studio には comannd line モードみたいなものがあるので、そこから実行するとフォルダ移動をしてくれます。
すると無事タワーディフェンスが遊べるようになりました。
まとめ
- Roblox Studio でタワーディフェンスキットを Toolbox から配置した直後はそのまま実行せず、
READMEの指示に従う。 - Luaコードか、エクスプローラー上のドラッグ&ドロップでタワーディフェンスのタワー配置・敵の生成・ウェーブ進行が正常に動くようになりました。