Experience Fuction SWEP error

Hey We have a star wars RP server and we have a lightsaber force power that gives experience but soon as more then one person starts meditating it stops giving exp


if self.Owner:KeyPressed(IN_ATTACK2) then
				local level = tonumber( self.Owner:GetNWInt("level"))
				timer.Create( "setforceTimer", 0.3, 0, function() if self:GetForce() < ( MaxForce + level ) then self:SetForce( self:GetForce() + 1 ) else return end end)
				timer.Create( "healTimer", 1, 0, function() heal(self) end)
				timer.Create( "expTimer", 1, 0, function() self.Owner:GiveExp(0.25) end)

Set the timer.Create name to something unique with SteamID.

How would one do that? I am new to this lua coding.

Change setforceTimer to “setforceTimer” … ply:SteamID(). This concatenates the timer name with the player’s SteamID.

Just tried, doesn’t work.

[editline]20th November 2016[/editline]


timer.Create( "setforceTimer" .. ply:SteamID(), 0.3, 0, function() if self:GetForce() < ( MaxForce + level ) then self:SetForce( self:GetForce() + 1 ) else return end end)

You have to do that with every timer.

If you mean like that,


 timer.Create( "setforceTimer" .. ply:SteamID(), 0.3, 0, function() if self:GetForce() < ( MaxForce + level ) then self:SetForce( self:GetForce() + 1 ) else return end end)
				timer.Create( "healTimer" .. ply:SteamID(), 1, 0, function() heal(self) end)
				timer.Create( "expTimer" .. ply:SteamID(), 1, 0, function() self.Owner:GiveExp(0.25) end) 

Its not working

[editline]20th November 2016[/editline]

The error produced when I try is



[ERROR] addons/star wars lightsabers/lua/weapons/weapon_lightsaber.lua:511: attempt to index global 'ply' (a nil value)
  1. think - addons/star wars lightsabers/lua/weapons/weapon_lightsaber.lua:511
   2. unknown - addons/star wars lightsabers/lua/weapons/weapon_lightsaber.lua:1442


Change ply to self.Owner

That worked, thank you.