Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local Players = game:GetService("Players")
- local player = Players.LocalPlayer
- local voteEvent = ReplicatedStorage:WaitForChild("VoteEvent")
- local voteResponseEvent = ReplicatedStorage:WaitForChild("VoteResponseEvent")
- local voteGui = nil
- -- ฟังก์ชันสร้าง GUI โหวต
- local function createVoteGui(offenderName, offenderUserId)
- if voteGui then
- voteGui:Destroy()
- end
- voteGui = Instance.new("ScreenGui")
- voteGui.Name = "VoteGui"
- voteGui.ResetOnSpawn = false
- voteGui.Parent = player:WaitForChild("PlayerGui")
- local frame = Instance.new("Frame", voteGui)
- frame.Size = UDim2.new(0.3, 0, 0.2, 0) -- ขนาดกลาง
- frame.Position = UDim2.new(0.35, 0, 0.4, 0) -- เริ่มตำแหน่งกลางหน้าจอ (สามารถลากย้ายได้)
- frame.BackgroundColor3 = Color3.new(0.2, 0.2, 0.2)
- frame.Active = true
- frame.Draggable = true
- local textLabel = Instance.new("TextLabel", frame)
- textLabel.Size = UDim2.new(1, 0, 0.4, 0)
- textLabel.Position = UDim2.new(0, 0, 0, 0)
- textLabel.BackgroundTransparency = 1
- textLabel.TextColor3 = Color3.new(1, 1, 1)
- textLabel.TextScaled = true
- textLabel.Text = "ผู้เล่น " .. offenderName .. " ได้ใช้โปรบินจริงไหม?"
- -- ปุ่ม "ใช่"
- local yesButton = Instance.new("TextButton", frame)
- yesButton.Size = UDim2.new(0.45, 0, 0.4, 0)
- yesButton.Position = UDim2.new(0.05, 0, 0.5, 0)
- yesButton.Text = "ใช่"
- yesButton.TextScaled = true
- -- ปุ่ม "ไม่"
- local noButton = Instance.new("TextButton", frame)
- noButton.Size = UDim2.new(0.45, 0, 0.4, 0)
- noButton.Position = UDim2.new(0.5, 0, 0.5, 0)
- noButton.Text = "ไม่"
- noButton.TextScaled = true
- yesButton.MouseButton1Click:Connect(function()
- voteResponseEvent:FireServer(offenderUserId, true)
- if voteGui then voteGui:Destroy() end
- end)
- noButton.MouseButton1Click:Connect(function()
- voteResponseEvent:FireServer(offenderUserId, false)
- if voteGui then voteGui:Destroy() end
- end)
- end
- -- รับสัญญาณจาก Server เพื่อแสดงหรือปิด GUI โหวต
- voteEvent.OnClientEvent:Connect(function(offenderName)
- if offenderName then
- -- หา offenderUserId จากชื่อ (ในตัวอย่างใช้การจับคู่จาก Players)
- local offenderUserId = nil
- for _, pl in pairs(Players:GetPlayers()) do
- if pl.Name == offenderName then
- offenderUserId = pl.UserId
- break
- end
- end
- if offenderUserId then
- createVoteGui(offenderName, offenderUserId)
- end
- else
- if voteGui then
- voteGui:Destroy()
- voteGui = nil
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment