いいね、その方が「サーバ主導」の思想ときれいに揃うね。
クライアントのトリガーなしで、サーバ側が 10 秒周期で外部アクセスする最小構成を、あなたのルールに合わせて出すよ。
🟦 ServerScript(10秒周期で HttpService アクセス)
-- Script
-- Path: ServerScriptService/HttpTicker.server.lua
local HttpService = game:GetService("HttpService")
-- Roblox Studio の [Game Settings] → [Security] で
-- "Allow HTTP Requests" を有効にしておくこと
local ENDPOINT = "https://example.com/api/ping"
while true do
task.wait(10) -- 10秒周期
local payload = {
source = "RobloxServer",
timestamp = os.time(),
}
local json = HttpService:JSONEncode(payload)
local success, result = pcall(function()
return HttpService:PostAsync(
ENDPOINT,
json,
Enum.HttpContentType.ApplicationJson
)
end)
if success then
print("[HttpTicker] Response:", result)
else
warn("[HttpTicker] HTTP Error:", result)
end
end
これで:
- クライアントのトリガーは一切不要
- サーバが 10 秒周期で外部 API にアクセス
- ログは Output に出る
ブログ用に書くなら:
- 「ServerScriptService に Script を 1 本置くだけ」
- 「仮想空間のセキュリティ設定で Allow HTTP Requests を有効にする」
- 「task.wait(10) で周期制御」
この 3 点を押さえると、きれいにまとまる。