Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Shows everyone the numbers even in local script?

Asked by
TechModel 118
3 years ago
Edited 3 years ago

This damage indication is supposed to be only visible when the person damages a humanoid and see the values themselves, not everyone in the server. The label is located in the started gui, not above the players head in-game, the screen, meaning if someone in the game did damge, everyone else did, and if I imagine multiple people damaging humanoid at once, it gets label values get chaoic. How to show only the player that does damage? Thanks

If there's an alternative and a better script that only shows the damage locally, and if you're willing to share, then I'm happy to.

wait(3)
local player = game.Players.LocalPlayer
local label = script.Parent

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.Position = UDim2.fromOffset(mouse.X,mouse.Y)
                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)

Answer this question