Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 既存のコードはここから始まります
- -- GUIを作成
- local ScreenGui = Instance.new("ScreenGui")
- local TextBox = Instance.new("TextBox")
- local SecondsGui = Instance.new("TextBox")
- local NotificationLabel = Instance.new("TextLabel")
- -- GUIのプロパティを設定
- ScreenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
- -- メッセージ入力用のテキストボックス
- TextBox.Parent = ScreenGui
- TextBox.AnchorPoint = Vector2.new(0.5, 0) -- アンカーポイントを中心上に設定
- TextBox.Position = UDim2.new(0.5, 0, 0.6, 10) -- テキストボックスを画面の中央より少し下に配置
- TextBox.Size = UDim2.new(0, 200, 0, 50)
- TextBox.PlaceholderText = "メッセージを入力"
- -- 秒数入力用のテキストボックス(秒数GUI)
- SecondsGui.Parent = ScreenGui
- SecondsGui.AnchorPoint = Vector2.new(0.5, 1) -- アンカーポイントを中心下に設定
- SecondsGui.Position = UDim2.new(0.5, 0, TextBox.Position.Y.Scale, TextBox.Position.Y.Offset - TextBox.Size.Y.Offset + 15) -- 秒数GUIをテキストボックスの直上に配置(位置を少し下に移動)
- SecondsGui.Size = UDim2.new(0, (200 * (3/5)) * (1/3), 0, 50 * (3/5)) -- 横幅を元の3分の1に設定
- SecondsGui.BackgroundColor3 = Color3.fromRGB(0, 0, 255) -- 色を青に設定
- SecondsGui.PlaceholderText = "秒数を入力"
- SecondsGui.Text = "1" -- 初期値を1に設定
- -- 通知ラベル
- NotificationLabel.Parent = ScreenGui
- NotificationLabel.AnchorPoint = Vector2.new(1, 1) -- アンカーポイントを右下に設定
- NotificationLabel.Position = UDim2.new(1, -10, 1, -10) -- ラベルを画面の右下に配置
- NotificationLabel.Size = UDim2.new(0, 200, 0, 50)
- NotificationLabel.TextColor3 = Color3.fromRGB(255, 255, 255) -- テキストの色を白に設定
- NotificationLabel.BackgroundColor3 = Color3.fromRGB(255, 0, 0) -- 背景色を赤に設定
- NotificationLabel.BackgroundTransparency = 1 -- 初期状態では透明に設定
- -- デフォルトのチャットシステムのSayMessageRequestイベントへの参照を取得
- local chatrem = game.ReplicatedStorage.DefaultChatSystemChatEvents.SayMessageRequest
- -- ボタンを作成
- local Button = Instance.new("TextButton")
- -- ボタンのプロパティを設定
- Button.Parent = ScreenGui
- Button.AnchorPoint = Vector2.new(0.5, 1) -- アンカーポイントを中心下に設定
- Button.Position = UDim2.new(0.5, 0, SecondsGui.Position.Y.Scale, SecondsGui.Position.Y.Offset - SecondsGui.Size.Y.Offset - 10) -- ボタンを秒数GUIの直上に配置(位置を少し下に移動)
- Button.Size = UDim2.new(0, 200, 0, 50)
- Button.TextColor3=Color3.fromRGB(255,255,255)
- Button.TextStrokeTransparency=0.8
- local isOn=false
- Button.Text="オフ"
- Button.BackgroundColor3=Color3.fromRGB(255,0,0)
- Button.MouseButton1Click:Connect(function()
- isOn=not isOn
- if isOn then
- Button.Text="オン"
- Button.BackgroundColor3=Color3.fromRGB(0,255,0)
- else
- Button.Text="オフ"
- Button.BackgroundColor3=Color3.fromRGB(255,0,0)
- end
- end)
- -- 既存のコードはここで終わります
- -- 新しいボタンGUIを作成
- local NewButton = Instance.new("TextButton")
- -- 新しいボタンのプロパティを設定
- NewButton.Parent = ScreenGui
- NewButton.AnchorPoint = Vector2.new(0.5, 1) -- アンカーポイントを中心下に設定
- NewButton.Position = UDim2.new(0.5, 0, Button.Position.Y.Scale, Button.Position.Y.Offset - Button.Size.Y.Offset - 10) -- ボタンを元のボタンの直上に配置(位置を少し下に移動)
- NewButton.Size = UDim2.new(0, 100 * (2/5), 0, 100 * (2/5)) -- 大きさを元の5分の2に設定し、形状を正方形にする
- NewButton.TextColor3=Color3.fromRGB(255,255,255)
- NewButton.TextStrokeTransparency=0.8
- NewButton.Draggable = true -- ドラッグ可能に設定
- local isGuiOn=true
- NewButton.Text="表示"
- NewButton.BackgroundColor3=Color3.fromRGB(0,255,0)
- NewButton.MouseButton1Click:Connect(function()
- isGuiOn=not isGuiOn
- if isGuiOn then
- NewButton.Text="表示"
- NewButton.BackgroundColor3=Color3.fromRGB(0,255,0)
- TextBox.Visible = true
- SecondsGui.Visible = true
- NotificationLabel.Visible = true
- Button.Visible = true
- else
- NewButton.Text="非表示"
- NewButton.BackgroundColor3=Color3.fromRGB(255,0,0)
- TextBox.Visible = false
- SecondsGui.Visible = false
- NotificationLabel.Visible = false
- Button.Visible = false
- end
- end)
- while true do
- if isOn then
- local secondsText = SecondsGui.Text -- 秒数GUIからテキストを取得
- local secondsNumber = tonumber(secondsText) -- テキストを数字に変換
- if secondsNumber then -- 数字が有効な場合
- NotificationLabel.Text = "" -- 通知ラベルのテキストをクリア
- NotificationLabel.BackgroundTransparency = 1 -- 背景色を透明に設定
- task.wait(secondsNumber) -- 入力された秒数だけ待つ
- local message = TextBox.Text -- テキストボックスからメッセージを取得
- if message ~= "" then -- メッセージが空でない場合のみ送信
- chatrem:FireServer(message, "All")
- print("Sent Message: " .. message) -- メッセージが送信されたことをコンソールに出力
- end
- else -- 数字が無効な場合(数字以外が入力された場合)
- NotificationLabel.Text = "これは数字ではありません。" -- 通知ラベルにエラーメッセージを表示
- NotificationLabel.BackgroundTransparency = 0 -- 背景色を不透明に設定
- end
- end
- task.wait(1) -- 次のチェックまで1秒待つ
- end
Advertisement
Add Comment
Please, Sign In to add comment