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?

robloxでassistant その49

Last updated at Posted at 2024-05-15

概要

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

練習問題

RemoteEventを使え。

手順

  • workspaceに、partを追加。
  • partに、clickdetectorを追加。
  • ReplicatedFirstに、localscriptを追加。
  • スクリプトを書く。
print("ok2")


local workspace = game.Workspace
local part = workspace:WaitForChild("Part")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = ReplicatedStorage:WaitForChild("RemoteEvent")
local clickdetector = part:WaitForChild("ClickDetector")
clickdetector.MouseClick:Connect(function(player)
	print("clicked")
	if Remote then
		print("fire")
		Remote:FireServer()
	end
end)

  • ServerScriptServiceに、scriptを追加。
  • スクリプトを書く。
print("ok0")

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = Instance.new("RemoteEvent", ReplicatedStorage)
Remote.OnServerEvent:Connect(function()
	print("fire server ok")
end)

game.Players.PlayerAdded:Connect(function(player)
	print("入った")
end)

game.Players.PlayerRemoving:Connect(function(player)
	print("出た")
end)

実行結果

08:51:52.673  ok0  -  サーバー - setup:2
  08:51:53.034  入った  -  サーバー - setup:11
  08:51:53.355  ok2  -  クライアント - LocalScript:1
  08:51:59.415  clicked  -  クライアント - LocalScript:10
  08:51:59.415  fire  -  クライアント - LocalScript:12
  08:51:59.441  fire server ok  -  サーバー - setup:7
  08:52:03.628  出た  -  サーバー - setup:15

以上。

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?