グループに入っている人のみプレイ
プレイヤーが指定グループに所属しているかを調べ、入室できる相手を制限します。
設定とコード例
ServerScriptServiceにScriptを追加します。groupIdの数値を自分のグループのIDに差し替えます。
local Players = game:GetService("Players")
local groupId = 1234567 -- 自分のグループIDに変更
local function onPlayerAdded(player)
if not player:IsInGroupAsync(groupId) then
player:Kick("このゲームをプレイするにはXXXグループに入る必要があります")
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
動作を確かめる
自分のグループIDに置き換え、メンバーと非メンバーで結果を確認します。