Survival Cart Aura

local _midPoint = World.FindObjectByName("MidPoint")
local _gameSettings = World.FindObjectByName("Game Settings")
local cart = script.parent
function _doAuras() -- heal/dmg tick every 2 seconds
    for k, player in pairs(Game.GetPlayers()) do
        local p = player:GetWorldPosition()
        local n = _midPoint:GetWorldPosition()
        local distanceSquared = (p - n).sizeSquared
        if distanceSquared < _G.Cart["_radiusRate"] * _G.Cart["_radiusRate"] then
            local distance = (p - n).size
            local healAmount = _G.Cart["_healRate"] 
           if(player.hitPoints + healAmount < 100) then
                   player.hitPoints = player.hitPoints + healAmount
           else 
                   player.hitPoints = 100
           end
            --player:AddResource("rounds",_G.Cart["_ammoRate"]) -- ammo regen
            
            if (player:GetResource(_G._resource4) < 197) then
                player:AddResource(_G._resource4,_G.Cart["_ammoRate"]) -- ammo regen
            end
            
        elseif(player:GetResource(_G._resource2) == 1) then --_atStation = 1
            -- they're at the station so do nothing
        else
            player:ApplyDamage(Damage.New(5.5)) -- they're not on the cart (nor at Station) so they take damage per tick..
            --print ("On cart: ",player:GetResource(_G._resource1))
        end
    end
    Task.Wait(2)
    _doAuras() -- infinite loop
end


_doAuras()

Latest Posts