1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Robloxでスタート時の場所を指定する

1
Posted at

概要

  • ゲーム開始時に何も指定しないと、座標(0, 0, 0)からスタートしてしまう
  • 特定の場所(たとえば家とか牢屋の中とか)からスタートしたい場合に使いましょう

image.png

準備するもの

  • ServerScriptServiceの中に1つのスクリプト

image.png

  • workspaceの中に1つのSpawnLocation(Workspaceのとなりの「+」マークから追加できます)

image.png

プログラミング

script.lua
-- Playersフォルダの中にいる全プレイヤーをとってくる
local Players = game:GetService("Players")

-- プレイヤーの生まれる場所(スポーンポイント)を、WorkspaceにあるSpawnPointというブロックの場所にする
local function onPlayerAdd(player)
	player.RespawnLocation = workspace.SpawnPoint
end

-- 各プレイヤーがゲームに入った瞬間に、onPlayerAdd関数が実行される
Players.PlayerAdded:Connect(onPlayerAdd)

チャレンジ課題

  • 以下のページを参考にして、複数のスタートポイントの中から、ランダムにえらんでスタートするように作ってみよう

https://blog.mitsuruog.info/2019/05/roblox-build-save-point

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?