Guest User

Client Side Script ( สคริปกันบิน ) สร้างโดย @modz_fbi

a guest
Mar 31st, 2025
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  2. local Players = game:GetService("Players")
  3. local player = Players.LocalPlayer
  4.  
  5. local voteEvent = ReplicatedStorage:WaitForChild("VoteEvent")
  6. local voteResponseEvent = ReplicatedStorage:WaitForChild("VoteResponseEvent")
  7.  
  8. local voteGui = nil
  9.  
  10. -- ฟังก์ชันสร้าง GUI โหวต
  11. local function createVoteGui(offenderName, offenderUserId)
  12. if voteGui then
  13. voteGui:Destroy()
  14. end
  15. voteGui = Instance.new("ScreenGui")
  16. voteGui.Name = "VoteGui"
  17. voteGui.ResetOnSpawn = false
  18. voteGui.Parent = player:WaitForChild("PlayerGui")
  19.  
  20. local frame = Instance.new("Frame", voteGui)
  21. frame.Size = UDim2.new(0.3, 0, 0.2, 0) -- ขนาดกลาง
  22. frame.Position = UDim2.new(0.35, 0, 0.4, 0) -- เริ่มตำแหน่งกลางหน้าจอ (สามารถลากย้ายได้)
  23. frame.BackgroundColor3 = Color3.new(0.2, 0.2, 0.2)
  24. frame.Active = true
  25. frame.Draggable = true
  26.  
  27. local textLabel = Instance.new("TextLabel", frame)
  28. textLabel.Size = UDim2.new(1, 0, 0.4, 0)
  29. textLabel.Position = UDim2.new(0, 0, 0, 0)
  30. textLabel.BackgroundTransparency = 1
  31. textLabel.TextColor3 = Color3.new(1, 1, 1)
  32. textLabel.TextScaled = true
  33. textLabel.Text = "ผู้เล่น " .. offenderName .. " ได้ใช้โปรบินจริงไหม?"
  34.  
  35. -- ปุ่ม "ใช่"
  36. local yesButton = Instance.new("TextButton", frame)
  37. yesButton.Size = UDim2.new(0.45, 0, 0.4, 0)
  38. yesButton.Position = UDim2.new(0.05, 0, 0.5, 0)
  39. yesButton.Text = "ใช่"
  40. yesButton.TextScaled = true
  41.  
  42. -- ปุ่ม "ไม่"
  43. local noButton = Instance.new("TextButton", frame)
  44. noButton.Size = UDim2.new(0.45, 0, 0.4, 0)
  45. noButton.Position = UDim2.new(0.5, 0, 0.5, 0)
  46. noButton.Text = "ไม่"
  47. noButton.TextScaled = true
  48.  
  49. yesButton.MouseButton1Click:Connect(function()
  50. voteResponseEvent:FireServer(offenderUserId, true)
  51. if voteGui then voteGui:Destroy() end
  52. end)
  53. noButton.MouseButton1Click:Connect(function()
  54. voteResponseEvent:FireServer(offenderUserId, false)
  55. if voteGui then voteGui:Destroy() end
  56. end)
  57. end
  58.  
  59. -- รับสัญญาณจาก Server เพื่อแสดงหรือปิด GUI โหวต
  60. voteEvent.OnClientEvent:Connect(function(offenderName)
  61. if offenderName then
  62. -- หา offenderUserId จากชื่อ (ในตัวอย่างใช้การจับคู่จาก Players)
  63. local offenderUserId = nil
  64. for _, pl in pairs(Players:GetPlayers()) do
  65. if pl.Name == offenderName then
  66. offenderUserId = pl.UserId
  67. break
  68. end
  69. end
  70. if offenderUserId then
  71. createVoteGui(offenderName, offenderUserId)
  72. end
  73. else
  74. if voteGui then
  75. voteGui:Destroy()
  76. voteGui = nil
  77. end
  78. end
  79. end)
  80.  
Advertisement
Add Comment
Please, Sign In to add comment