概要
robloxでassistant、やってみた。
練習問題やってみた。
練習問題
プラグインでリモートイベントをデプロイせよ。
写真
サンプルコード
local tb = plugin:CreateToolbar("test5")
local button = tb:CreateButton("test desu", "run", "http://www.roblox.com/asset/?id=10164183611")
button.ClickableWhenViewportHidden = true
local widgetInfo = DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, false, true, 300, 200)
local dragSourceWidget = plugin:CreateDockWidgetPluginGui("Customization", widgetInfo)
local testButton1 = Instance.new("TextButton")
local testButton2 = Instance.new("TextButton")
local testButton3 = Instance.new("TextButton")
testButton1.BorderSizePixel = 0
testButton1.TextSize = 20
testButton1.TextColor3 = Color3.new(0.32549, 0.32549, 0.32549)
testButton1.AnchorPoint = Vector2.new(0.5, 0.5)
testButton1.Size = UDim2.new(1, 0, 0.1, 0)
testButton1.Position = UDim2.new(0.5, 0, 0.1, 0)
testButton1.SizeConstraint = Enum.SizeConstraint.RelativeYY
testButton1.Text = "deploy"
testButton1.Parent = dragSourceWidget
testButton2.BorderSizePixel = 0
testButton2.TextSize = 20
testButton2.TextColor3 = Color3.new(0.32549, 0.32549, 0.32549)
testButton2.AnchorPoint = Vector2.new(0.5, 0.5)
testButton2.Size = UDim2.new(1, 0, 0.1, 0)
testButton2.Position = UDim2.new(0.5, 0, 0.3, 0)
testButton2.SizeConstraint = Enum.SizeConstraint.RelativeYY
testButton2.Text = "button2"
testButton2.Parent = dragSourceWidget
testButton3.BorderSizePixel = 0
testButton3.TextSize = 20
testButton3.TextColor3 = Color3.new(0.32549, 0.32549, 0.32549)
testButton3.AnchorPoint = Vector2.new(0.5, 0.5)
testButton3.Size = UDim2.new(1, 0, 0.1, 0)
testButton3.Position = UDim2.new(0.5, 0, 0.5, 0)
testButton3.SizeConstraint = Enum.SizeConstraint.RelativeYY
testButton3.Text = "button3"
testButton3.Parent = dragSourceWidget
testButton1.MouseButton1Down:Connect(function()
if game:GetService("ReplicatedFirst"):FindFirstChild("helloscript") then
game.ReplicatedFirst.helloscript:Destroy();
end
local helloScript = Instance.new("LocalScript")
helloScript.Name = "helloscript"
helloScript.Parent = game.ReplicatedFirst
helloScript.Source = [[
local workspace = game.Workspace
local part = Instance.new("Part", workspace)
part.Position = Vector3.new(0, 1, -9)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = ReplicatedStorage:WaitForChild("RemoteEvent")
local clickDetector = Instance.new("ClickDetector")
clickDetector.Parent = part
clickDetector.MouseClick:Connect(function(player)
print("clicked")
if Remote then
print("fire")
Remote:FireServer()
end
end)
]]
if game:GetService("ServerScriptService"):FindFirstChild("ohiscript") then
game.ServerScriptService.ohiscript:Destroy();
end
local helloScript = Instance.new("Script")
helloScript.Name = "ohiscript"
helloScript.Parent = game.ServerScriptService
helloScript.Source = [[
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = Instance.new("RemoteEvent", ReplicatedStorage)
Remote.OnServerEvent:Connect(function(player)
print("fire server ok")
print(player.Name)
local fire = Instance.new("Fire")
fire.Heat = 10
fire.Color = Color3.new(1, 0, 0)
fire.SecondaryColor = Color3.new(1, 1, 1)
fire.Size = math.max(10, 10)
fire.Parent = workspace
end)
]]
print("ok1")
end)
testButton2.MouseButton1Down:Connect(function()
print("ok2")
end)
testButton3.MouseButton1Down:Connect(function()
print("ok3")
end)
button.Click:Connect(function()
dragSourceWidget.Enabled = true
end)
以上。