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

Is it possible to use Magnitude to inflict damage to players?

Asked by
neoG457 315 Moderation Voter
8 years ago

I haven't got a script to go with this but I just want to know if it's possible and if it is how? Because I have no clue.

1
Sure, hum.Health = hum.Health - (250-(mag*5)). Basically for every stud you're away from the magnitude point, the maximum possible health to reduce gets reduced by 5. If you provide a script I'll be able to help you out more! M39a9am3R 3210 — 8y
0
Ill try to neoG457 315 — 8y

1 answer

Log in to vote
1
Answered by
Wutras 294 Moderation Voter
8 years ago

Yes, it is possible. I'll do some script here with an explanation.

local redpart = Instance.new("Part", workspace)
redpart.BrickColor = BrickColor.Red()
RedPartDoesDamage = coroutine.create(function()
    for _, poss in pairs(workspace:GetChildren()) do
        if poss:FindFirstChild("Humanoid") then
            print("Hi")
            if poss.Torso then
                print("Hi2")
                if (poss.Torso.Position - redpart.Position).magnitude <= 10 then
                    print("Hi3")
                    while (poss.Torso.Position - redpart.Position).magnitude <= 10 do
                        poss.Humanoid.Health = poss.Humanoid.Health - 10%poss.Humanoid.MaxHealth
                        wait(1)
                    end
                end
            end
        end
    end
end)
script.Parent.MouseClick:connect(function()
    coroutine.resume(RedPartDoesDamage)
end)

This script is basically searching through the workspace for Models with a Humanoid and a Torso inside and then do damage if they're within a distance of 10 Studs or less. You should place it into a ClickDetector.

Ad

Answer this question