tomoneko

逃げる

Jan 8th, 2024 (edited)
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. local FillColor = Color3.fromRGB(255,0,0)
  2. local ZeroHealthColor = Color3.fromRGB(0,255,0) -- 体力が0のときの色を追加
  3. local DepthMode = "AlwaysOnTop"
  4. local FillTransparency = 0.5
  5. local OutlineColor = Color3.fromRGB(255,255,255)
  6. local OutlineTransparency = 0
  7.  
  8. local CoreGui = game:FindService("CoreGui")
  9. local Players = game:FindService("Players")
  10. local connections = {}
  11.  
  12. local Storage = Instance.new("Folder")
  13. Storage.Parent = CoreGui
  14. Storage.Name = "Highlight_Storage"
  15.  
  16. -- ハイライトの状態(デフォルトはオン)
  17. local isHighlightOn = true
  18.  
  19. local function updateHighlightColor(char, Highlight)
  20. if char and char:FindFirstChild("Humanoid") then
  21. if char.Humanoid.Health == 0 then
  22. Highlight.FillColor = ZeroHealthColor
  23. else
  24. Highlight.FillColor = FillColor
  25. end
  26. end
  27. end
  28.  
  29. local function Highlight(plr)
  30. local Highlight = Instance.new("Highlight")
  31. Highlight.Name = plr.Name
  32. Highlight.FillColor = FillColor
  33. Highlight.DepthMode = DepthMode
  34. Highlight.FillTransparency = FillTransparency
  35. Highlight.OutlineColor = OutlineColor
  36. Highlight.OutlineTransparency = 0
  37. Highlight.Parent = Storage
  38.  
  39. local function updateHighlightColor(char)
  40. if char and char:FindFirstChild("Humanoid") then
  41. if char.Humanoid.Health == 0 then
  42. Highlight.FillColor = ZeroHealthColor
  43. else
  44. Highlight.FillColor = FillColor
  45. end
  46. end
  47. end
  48.  
  49. local function setupCharacter(char)
  50. Highlight.Adornee = char
  51. updateHighlightColor(char) -- 体力の初期値に基づいて色を設定
  52. char.Humanoid.HealthChanged:Connect(function(health)
  53. updateHighlightColor(char) -- 体力が変化したときに色を更新
  54. end)
  55. end
  56.  
  57. local plrchar = plr.Character
  58. if plrchar then
  59. setupCharacter(plrchar)
  60. end
  61.  
  62. connections[plr] = plr.CharacterAdded:Connect(function(char)
  63. if isHighlightOn then -- ハイライトがオンの場合のみ、新しいキャラクターを追跡します。
  64. setupCharacter(char)
  65. end
  66. end)
  67.  
  68. -- 1秒ごとに色を確認し、必要に応じて修正
  69. game:GetService("RunService").Heartbeat:Connect(function()
  70. if isHighlightOn and plr.Character then
  71. updateHighlightColor(plr.Character)
  72. end
  73. end)
  74. end
  75.  
  76. Players.PlayerAdded:Connect(Highlight)
  77. for i,v in next, Players:GetPlayers() do
  78. Highlight(v)
  79. end
  80.  
  81. Players.PlayerRemoving:Connect(function(plr)
  82. local plrname = plr.Name
  83. if Storage[plrname] then
  84. Storage[plrname]:Destroy()
  85. end
  86. if connections[plr] then
  87. connections[plr]:Disconnect()
  88. end
  89. end)
  90.  
Advertisement
Add Comment
Please, Sign In to add comment