tomoneko

自動chat

Oct 26th, 2023 (edited)
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.80 KB | None | 0 0
  1. -- 既存のコードはここから始まります
  2.  
  3. -- GUIを作成
  4. local ScreenGui = Instance.new("ScreenGui")
  5. local TextBox = Instance.new("TextBox")
  6. local SecondsGui = Instance.new("TextBox")
  7. local NotificationLabel = Instance.new("TextLabel")
  8.  
  9. -- GUIのプロパティを設定
  10. ScreenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
  11.  
  12. -- メッセージ入力用のテキストボックス
  13. TextBox.Parent = ScreenGui
  14. TextBox.AnchorPoint = Vector2.new(0.5, 0) -- アンカーポイントを中心上に設定
  15. TextBox.Position = UDim2.new(0.5, 0, 0.6, 10) -- テキストボックスを画面の中央より少し下に配置
  16. TextBox.Size = UDim2.new(0, 200, 0, 50)
  17. TextBox.PlaceholderText = "メッセージを入力"
  18.  
  19. -- 秒数入力用のテキストボックス(秒数GUI)
  20. SecondsGui.Parent = ScreenGui
  21. SecondsGui.AnchorPoint = Vector2.new(0.5, 1) -- アンカーポイントを中心下に設定
  22. SecondsGui.Position = UDim2.new(0.5, 0, TextBox.Position.Y.Scale, TextBox.Position.Y.Offset - TextBox.Size.Y.Offset + 15) -- 秒数GUIをテキストボックスの直上に配置(位置を少し下に移動)
  23. SecondsGui.Size = UDim2.new(0, (200 * (3/5)) * (1/3), 0, 50 * (3/5)) -- 横幅を元の3分の1に設定
  24. SecondsGui.BackgroundColor3 = Color3.fromRGB(0, 0, 255) -- 色を青に設定
  25. SecondsGui.PlaceholderText = "秒数を入力"
  26. SecondsGui.Text = "1" -- 初期値を1に設定
  27.  
  28. -- 通知ラベル
  29. NotificationLabel.Parent = ScreenGui
  30. NotificationLabel.AnchorPoint = Vector2.new(1, 1) -- アンカーポイントを右下に設定
  31. NotificationLabel.Position = UDim2.new(1, -10, 1, -10) -- ラベルを画面の右下に配置
  32. NotificationLabel.Size = UDim2.new(0, 200, 0, 50)
  33. NotificationLabel.TextColor3 = Color3.fromRGB(255, 255, 255) -- テキストの色を白に設定
  34. NotificationLabel.BackgroundColor3 = Color3.fromRGB(255, 0, 0) -- 背景色を赤に設定
  35. NotificationLabel.BackgroundTransparency = 1 -- 初期状態では透明に設定
  36.  
  37. -- デフォルトのチャットシステムのSayMessageRequestイベントへの参照を取得
  38. local chatrem = game.ReplicatedStorage.DefaultChatSystemChatEvents.SayMessageRequest
  39.  
  40. -- ボタンを作成
  41. local Button = Instance.new("TextButton")
  42.  
  43. -- ボタンのプロパティを設定
  44. Button.Parent = ScreenGui
  45. Button.AnchorPoint = Vector2.new(0.5, 1) -- アンカーポイントを中心下に設定
  46. Button.Position = UDim2.new(0.5, 0, SecondsGui.Position.Y.Scale, SecondsGui.Position.Y.Offset - SecondsGui.Size.Y.Offset - 10) -- ボタンを秒数GUIの直上に配置(位置を少し下に移動)
  47. Button.Size = UDim2.new(0, 200, 0, 50)
  48. Button.TextColor3=Color3.fromRGB(255,255,255)
  49. Button.TextStrokeTransparency=0.8
  50.  
  51. local isOn=false
  52.  
  53. Button.Text="オフ"
  54. Button.BackgroundColor3=Color3.fromRGB(255,0,0)
  55.  
  56. Button.MouseButton1Click:Connect(function()
  57. isOn=not isOn
  58.  
  59. if isOn then
  60. Button.Text="オン"
  61. Button.BackgroundColor3=Color3.fromRGB(0,255,0)
  62. else
  63. Button.Text="オフ"
  64. Button.BackgroundColor3=Color3.fromRGB(255,0,0)
  65. end
  66. end)
  67.  
  68. -- 既存のコードはここで終わります
  69.  
  70. -- 新しいボタンGUIを作成
  71. local NewButton = Instance.new("TextButton")
  72.  
  73. -- 新しいボタンのプロパティを設定
  74. NewButton.Parent = ScreenGui
  75. NewButton.AnchorPoint = Vector2.new(0.5, 1) -- アンカーポイントを中心下に設定
  76. NewButton.Position = UDim2.new(0.5, 0, Button.Position.Y.Scale, Button.Position.Y.Offset - Button.Size.Y.Offset - 10) -- ボタンを元のボタンの直上に配置(位置を少し下に移動)
  77. NewButton.Size = UDim2.new(0, 100 * (2/5), 0, 100 * (2/5)) -- 大きさを元の5分の2に設定し、形状を正方形にする
  78. NewButton.TextColor3=Color3.fromRGB(255,255,255)
  79. NewButton.TextStrokeTransparency=0.8
  80. NewButton.Draggable = true -- ドラッグ可能に設定
  81.  
  82. local isGuiOn=true
  83.  
  84. NewButton.Text="表示"
  85. NewButton.BackgroundColor3=Color3.fromRGB(0,255,0)
  86.  
  87. NewButton.MouseButton1Click:Connect(function()
  88. isGuiOn=not isGuiOn
  89.  
  90. if isGuiOn then
  91. NewButton.Text="表示"
  92. NewButton.BackgroundColor3=Color3.fromRGB(0,255,0)
  93. TextBox.Visible = true
  94. SecondsGui.Visible = true
  95. NotificationLabel.Visible = true
  96. Button.Visible = true
  97. else
  98. NewButton.Text="非表示"
  99. NewButton.BackgroundColor3=Color3.fromRGB(255,0,0)
  100. TextBox.Visible = false
  101. SecondsGui.Visible = false
  102. NotificationLabel.Visible = false
  103. Button.Visible = false
  104. end
  105. end)
  106.  
  107. while true do
  108. if isOn then
  109. local secondsText = SecondsGui.Text -- 秒数GUIからテキストを取得
  110. local secondsNumber = tonumber(secondsText) -- テキストを数字に変換
  111.  
  112. if secondsNumber then -- 数字が有効な場合
  113. NotificationLabel.Text = "" -- 通知ラベルのテキストをクリア
  114. NotificationLabel.BackgroundTransparency = 1 -- 背景色を透明に設定
  115.  
  116. task.wait(secondsNumber) -- 入力された秒数だけ待つ
  117.  
  118. local message = TextBox.Text -- テキストボックスからメッセージを取得
  119. if message ~= "" then -- メッセージが空でない場合のみ送信
  120. chatrem:FireServer(message, "All")
  121. print("Sent Message: " .. message) -- メッセージが送信されたことをコンソールに出力
  122. end
  123.  
  124. else -- 数字が無効な場合(数字以外が入力された場合)
  125. NotificationLabel.Text = "これは数字ではありません。" -- 通知ラベルにエラーメッセージを表示
  126. NotificationLabel.BackgroundTransparency = 0 -- 背景色を不透明に設定
  127. end
  128.  
  129. end
  130.  
  131. task.wait(1) -- 次のチェックまで1秒待つ
  132. end
  133.  
Advertisement
Add Comment
Please, Sign In to add comment