I’ve tweaked this script by adding adjustments which the label is shown on the screen GUI showing the damage value on the screen. So why does it show damage to everyone when I use it as a local script? I only want the damage value shown only to the player that does damage. I know there are a bit of errors that the text doesn’t extend the 3 seconds every time I hit, but that’s fine for now and something about recursion. If there are any better scripts or something that can help and you’re willing to share, then I’ll use that information.
wait(3)
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local label = script.Parent
function updatePos()
label.Position = UDim2.fromOffset(mouse.X,mouse.Y)
end
mouse.Move:Connect(updatePos)
function Track(Humanoid)
local Last = Humanoid.Health
local function HealthChanged(Left)
if Left < Last then
local Part = Humanoid.Parent:FindFirstChildWhichIsA("BasePart")
if Part then
label.TextTransparency = 0
label.Visible = true
label.Text = math.floor(Last - Left)
wait(.1)
if Left < Last then
wait(3)
for i = 0, 1, 0.05 do
label.TextTransparency = i
wait(.05)
end
label.Visible = false
return
else
wait(3)
for i = 0, 1, 0.05 do
label.TextTransparency = i
wait(.05)
label.Visible = false
end
end
end
Last = Left
end
end
Humanoid.HealthChanged:Connect(HealthChanged)
end
local D = game.Workspace:GetDescendants()
for i = 1,#D do
if D[i]:IsA("Humanoid") then
Track(D[i])
end
end
function Added(item)
if item:IsA("Humanoid") then
Track(item)
end
end
game.Workspace.DescendantAdded:Connect(Added)