render.DrawSphere Dynamic size help

I’m trying to make it so that render.DrawSphere changes size and its all handled in the think hook. I’ve tried this code below
[lua]
function ENT:Initialize()
end
function ENT:Draw()
–self.BaseClass.Draw(self)
self:DrawModel()
–local tr = LocalPlayer():GetEyeTrace()
render.SetColorMaterial()
render.DrawSphere(self:GetPos(),size2,50,50,Color(250,0,0,100))
self:EmitSound(“boom/sphere.wav”)
end

function ENT:Think()
size2 = 50
if size2>=1000 then
size2=size2-150
elseif size2>=149 then
size2=size2+200
elseif size2==50 then
size2=size2+100
end

end
[/lua]

and it doesn’t work. I currently want the entity to scale up to 1000 and then once it hits 1000 go back down to its original size. Currently it just spawns and does size2+100 and goes to size2 = 150 and then stays like that. Any help?

Can you try running this? I didn’t test it because i don’t have gmod installed right now.
[lua]
function ENT:Initialize()
self.Size=50
self.Growing=true
self.LastTime=CurTime()
end
function ENT:Draw()
–self.BaseClass.Draw(self)
self:DrawModel()
–local tr = LocalPlayer():GetEyeTrace()
render.SetColorMaterial()
render.DrawSphere(self:GetPos(), self.Size, 50, 50, Color(250,0,0,100))
self:EmitSound(“boom/sphere.wav”)
end

function ENT:Think()
local currenttime=CurTime()
local d=(currenttime-self.LastTime)

if self.Growing==True then
	self.Size=math.Clamp(self.Size+75*d, 0, 1000)
else
	self.Size=math.Clamp(self.Size-150*d, 50, 1000)
end
if self.Size==1000 then self.Growing=false end
if self.Size==50 then self.Growing=true end

end
[/lua]

Didn’t work. It just kept the sphere at size 50 :confused:

Can you make sure you have the recent paste? I edited my post because i added an unneeded /1000 at local d=(currenttime-self.LastTime) turning it into local d=(currenttime-self.LastTime)/1000.

Yep and it didn’t work still the same as the previous time :confused:

This should do it.
[lua]
function ENT:Initialize()
self.Size=50
self.Growing=true
end
function ENT:Draw()
–self.BaseClass.Draw(self)
self:DrawModel()
–local tr = LocalPlayer():GetEyeTrace()
render.SetColorMaterial()
render.DrawSphere(self:GetPos(), self.Size, 50, 50, Color(250,0,0,100))
self:EmitSound(“boom/sphere.wav”)
end

function ENT:Think()
local d=FrameTime()

if self.Growing==True then
	self.Size=math.Clamp(self.Size+75*d, 0, 1000)
else
	self.Size=math.Clamp(self.Size-150*d, 50, 1000)
end
if self.Size==1000 then self.Growing=false end
if self.Size==50 then self.Growing=true end

end
[/lua]

Nothing my dude. I appreciate your help though! It still stays at 50 when i spawn it in.

[lua]
function ENT:Initialize()
self.Size=50
self.Growing=true
end
function ENT:Draw()
–self.BaseClass.Draw(self)
self:DrawModel()
–local tr = LocalPlayer():GetEyeTrace()
render.SetColorMaterial()
render.DrawSphere(self:GetPos(), self.Size, 50, 50, Color(250,0,0,100))
self:EmitSound(“boom/sphere.wav”)
end

function ENT:Think()
local d=FrameTime()

if self.Growing==true then
	self.Size=math.Clamp(self.Size+75*d, 0, 1000)
else
	self.Size=math.Clamp(self.Size-150*d, 50, 1000)
end
if self.Size==1000 then self.Growing=false end
if self.Size==50 then self.Growing=true end

end
[/lua]
If that doesn’t work can you add me on steam? I capitalised True by accident :suicide:

It works now! I’ll add you on steam anyways if you don’t mind :slight_smile: