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

I'm the one who's getting flung or burned?

Asked by 8 years ago

My friend gave it to me but I have no idea how to fix it, the purpose of it was to fling or burn players that will come near me

_G.PLS_DIE = false
local TYPE = "FLING"
--// TYPES:
----// BURN: 
--        burns all plrs within a 10 stud radius of the local player
----// FLING:
--        flings a plr if they come within 10 studs of the local player

Burn = function(Plr)
    for _, L in pairs(Plr.Character:GetChildren()) do
        Instance.new("Fire", L)
    end
    spawn(function()
        while Plr.Character.Humanoid.Health > 0 and wait(0.1) do
            Plr.Character.Humanoid.Health = Plr.Character.Humanoid.Health - 5
        end
    end)
end

Fling = function(Plr)
    local x, z
    repeat
        x = math.random(-150, 150)
        z = math.random(-150, 150)
    until
        math.abs(x) >= 50 and math.abs(z) >= 50
    Plr.Character.Humanoid.Sit = true
    Plr.Character.Torso.Velocity = Vector3.new(0, 0, 0)
    local BF = Instance.new("BodyForce", Plr.Character.Torso)
    BF.Force = Vector3.new(x * 4, 150 * 5, z * 4)
    wait(0.1)
    BF:Destroy()
end

while _G.PLS_DIE == true and wait(1/30) do
    for _, Plr in pairs(game:GetService("Players"):GetChildren()) do
        if Plr:DistanceFromCharacter(game.Players.LocalPlayer.Character["Left Arm"].Position) <= 35 then
            if TYPE == "BURN" then
                Burn(Plr)
            elseif TYPE == "FLING" then
                Fling(Plr)
            end
        end
    end
end
0
It should work fine. Issue is that you're close to yourself. User#6546 35 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Might be just a problem with the Class Function, try using something like this:

while _G.PLS_DIE == true and wait(1/30) do
    for i, v in pairs(game.Players:GetChildren()) do
        if (v.Character.Torso.Position - game.Players.LocalPlayer.Character.Torso.Position).magnitude <= 35 and v ~= game.Players.LocalPlayer then
            if type == "BURN" then
                Burn(v)
            elseif type == "FLING" then
                Fling(v)
            end
        end
    end
end
Ad

Answer this question