My spawnpoints prints an error.


attempt to index local 'ply' (a nil value)

I never get these, could someone help me get this working?

LINE 19 and 20:
[lua]
ply:GetTable().maxspawn = ply:GetTable().maxspawn + 1
ply:GetTable().Spawnpoint = self.Entity
[/lua]
and ply are a local variable:



    local ply = self.Owner


Help, please… :slight_smile:

Can we have all the function please?

self.Owner isn’t valid. Also, you don’t need to do ply:GetTable(). ply.maxspawn = ply.maxspawn + 1 would work.

(self.Entity is the same as self, by the way.)

self.Owner should be valid as long as he sets the owner during the purchase function, assuming you’re using basewars.

Nope, I am doing a spawnpoint in my darkrp… lawl

[editline]16th February 2013[/editline]

[lua]
AddCSLuaFile(“cl_init.lua”)
AddCSLuaFile(“shared.lua”)
include(‘shared.lua’)

function ENT:Initialize()

self.Entity:SetModel( "models/props_trainstation/trainstation_clock001.mdl")
self.Entity:PhysicsInit(SOLID_VPHYSICS)
self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
self.Entity:SetSolid(SOLID_VPHYSICS)
self.Entity:SetAngles(Angle(-90, 0, 0))
local ply = self.Owner
local phys = self.Entity:GetPhysicsObject()
phys:EnableMotion(false)
if(phys:IsValid()) then phys:Wake() end
self.Entity:SetNWInt("damage",100)
local spawnpointp = true
ply:GetTable().maxspawn = ply:GetTable().maxspawn + 1
ply:GetTable().Spawnpoint = self.Entity

end

function ENT:Think( )
if (IsValid(self.Owner)!=true) then
self.Entity:Remove()
end
end

function ENT:OnRemove( )
local ply = self.Owner
if IsValid(ply) then
ply:GetTable().maxspawn = ply:GetTable().maxspawn - 1
end
end
[/lua]

Are you setting the owner in the purchase or however the player is getting the spawnpoint?