Advertisement
uor

Untitled

uor
May 5th, 2023
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local Debris = game:GetService("Debris")
  3. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  4.  
  5. local remoteEvent = Instance.new("RemoteEvent")
  6. remoteEvent.Name = "ShowDamage"
  7. remoteEvent.Parent = ReplicatedStorage
  8.  
  9. local function onRightClick(player)
  10. print("Right-click detected")
  11. local character = player.Character
  12. if not character then return end
  13.  
  14. local humanoid = character:FindFirstChild("Humanoid")
  15. if not humanoid then return end
  16.  
  17. local target = player:GetMouse().Target
  18. if not target then return end
  19.  
  20. local targetPlayer = Players:GetPlayerFromCharacter(target.Parent)
  21. if not targetPlayer then return end
  22.  
  23. local targetHumanoid = target.Parent:FindFirstChild("Humanoid")
  24. if not targetHumanoid then return end
  25.  
  26. -- Play punch animation
  27. local animation = Instance.new("Animation")
  28. animation.AnimationId = "rbxassetid://13337873546"
  29. local animationTrack = humanoid:LoadAnimation(animation)
  30. animationTrack:Play()
  31. print("Playing punch animation")
  32.  
  33. -- Apply damage to the target player
  34. targetHumanoid:TakeDamage(10)
  35. print("Applying damage to target player")
  36.  
  37. -- Show damage on the target player's client
  38. remoteEvent:FireClient(targetPlayer, target, 10)
  39. end
  40.  
  41. local function onPlayerAdded(player)
  42. player:GetMouse().Button2Down:Connect(function()
  43. onRightClick(player)
  44. end)
  45. end
  46.  
  47. Players.PlayerAdded:Connect(onPlayerAdded)
  48.  
  49. -- ServerScriptService
  50. local function onShowDamage(player, part, damage)
  51. print("Showing damage on client")
  52. local damageLabel = Instance.new("BillboardGui")
  53. damageLabel.Adornee = part
  54. damageLabel.Size = UDim2.new(0, 100, 0, 50)
  55. damageLabel.StudsOffset = Vector3.new(0, 3, 0)
  56.  
  57. local textLabel = Instance.new("TextLabel")
  58. textLabel.BackgroundTransparency = 1
  59. textLabel.Size = UDim2.new(1, 0, 1, 0)
  60. textLabel.TextColor3=Color3.new(1,0,0)
  61. textLabel.TextStrokeTransparency=0
  62. textLabel.TextScaled=true
  63. textLabel.Text="-"..tostring(damage)
  64. textLabel.Parent=damageLabel
  65.  
  66. damageLabel.Parent=player.PlayerGui
  67.  
  68. Debris:AddItem(damageLabel,1)
  69. end
  70.  
  71. remoteEvent.OnServerEvent:Connect(onShowDamage)
  72.  
  73. -- StarterPlayerScripts
  74. local function onShowDamageClient(part,damage)
  75. print("Showing damage on client")
  76. local player=Players.LocalPlayer
  77. local character=player.Character
  78. if not character then return end
  79.  
  80. local humanoidRootPart=character:FindFirstChild("HumanoidRootPart")
  81. if not humanoidRootPart then return end
  82.  
  83. local distance=(humanoidRootPart.Position-part.Position).Magnitude
  84. if distance>100 then return end
  85.  
  86. local damageLabel=Instance.new("BillboardGui")
  87. damageLabel.Adornee=part
  88. damageLabel.Size=UDim2.new(0,100,0,50)
  89. damageLabel.StudsOffset=Vector3.new(0,3,0)
  90.  
  91. local textLabel=Instance.new("TextLabel")
  92. textLabel.BackgroundTransparency=1
  93. textLabel.Size=UDim2.new(1,0,1,0)
  94. textLabel.TextColor3=Color3.new(1,0,0)
  95. textLabel.TextStrokeTransparency=0
  96. textLabel.TextScaled=true
  97. textLabel.TextStrokeColor3=Color3.fromRGB(255,255,255)
  98. textLabel.Font=Enum.Font.SourceSansBold
  99. textLabel.TextStrokeTransparency=0
  100. textLabel.TextSize=30
  101. textLabel.ZIndex=10
  102. textLabel.Text="-"..tostring(damage)
  103. textLabel.Parent=damageLabel
  104.  
  105. damageLabel.Parent=player.PlayerGui
  106.  
  107. Debris:AddItem(damageLabel,1)
  108. end
  109.  
  110. remoteEvent.OnClientEvent:Connect(onShowDamageClient)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement