0
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 1 year has passed since last update.

robloxでassistant その108

Posted at

概要

robloxでassistantやってみた。
練習問題やってみた。

練習問題

スクリプトだけで、タッチするとカメラの視点を変更するパーツを作れ。

手順

  • ReplicatedFirstに、LocalScriptを追加。
  • スクリプトを書く。

local ReplicatedStorage = game:GetService("ReplicatedStorage");
local SetCameraType = ReplicatedStorage:WaitForChild("SetCameraType");
local CurrentCamera = workspace.CurrentCamera;
local changedCamera = false;
if not changedCamera then
	print("ok2")
	SetCameraType.OnClientEvent:Connect(function(cameraPart)
		CurrentCamera.CameraType = Enum.CameraType.Scriptable;
		CurrentCamera.CFrame = CurrentCamera.CFrame + CurrentCamera.CFrame.LookVector * (-2);
		wait(1)
		CurrentCamera.CameraType = Enum.CameraType.Custom;
	end)
end

  • ServerScriptServiceに、Scriptを追加。
  • スクリプトを書く。
local part = Instance.new("Part", workspace)
part.Position = Vector3.new(0, 1, -10)
local Players = game:GetService("Players");
local ReplicatedStorage = game:GetService("ReplicatedStorage");
local cameraPart = workspace:FindFirstChild("CameraPart");
local setCameraType = Instance.new("RemoteEvent");
setCameraType.Name = "SetCameraType";
setCameraType.Parent = ReplicatedStorage;
part.Touched:Connect(function(hit)
	local Character = hit.Parent;
	local Humanoid = Character:FindFirstChild("Humanoid");
	if Humanoid then
		local Player = Players:GetPlayerFromCharacter(Character);
		setCameraType:FireClient(Player, cameraPart);
	end
end)

写真

image.png

以上。

0
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
0
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?