Checking if a timer exists on one client


function PlayerHasHurtABot(ply)
    if ply:IsBot() then
        timer.Create( "PleaseWork", 0, 0, function()
            ply:SetVelocity( (ply:GetAimVector() * 30 ) )
        end)
    end
end
hook.Add( "PlayerHurt", "BotHasBeenHurtHopeThisWorks", PlayerHasHurtABot )



function GetRidOfDaTimerOnSpawn(ply)
if ply:IsBot() then
timer.Create( "PleaseWork2", 0, 1, function()
if timer.Exists("PleaseWork") then timer.Destroy("PleaseWork")
end
end)
end
end
hook.Add( "PlayerSpawn", "MakeTheBotNotGoPsycho", GetRidOfDaTimerOnSpawn )


You see, what happens with this code is that it works fine, however, it destroys the whole timer I created on all bots, and(might) create a global timer that is called on all bots instead of one(not sure if this happens, can anyne tell me judging by what the code says?)

Make the timers unique, such as creating the timer with the player’s UID at the end



function plyspawn(ply)
if(timer.Exists(ply:EntIndex().."_Update"))then
   print("Timer exists!!!!")
else
local delay = 5
local times = 0
timer.Create(ply:EntIndex().."_Update", delay, times, function()
ply:SetVelocity( (ply:GetAimVector() * 30 ) )
end)
end
end
hook.Add("PlayerSpawn", "playerspawned", plyspawn)


I think that will work. Sorry i coded it in here so its going to not be formatted. Hoped it helped!

If all the bots are going to have the same code you could insert the bot into a table once created and just have your table loop through it using for i,v in pairs

Not sure if it would be more efficient though, but it would be a bit simpler imo

I like to use timer.Create( tostring( ent ) …"_UniqueIdentifier" )