Rotating Entity

So I’ve been trying to create a rotating entity for a good day or two now, and I can’t seem to get it to rotate. I’ve tried using other scripts as resources but I still can’t figure out what is wrong.

Here is what I have so far:


function SpawnEnts( )
local bubble = ents.Create( “entity1” )
bubble:SetPos( Vector( 1019.322815, 439.279907, 50.031250 ) )
bubble:Spawn( )
hook.Add( “InitPostEntity”, “SpawnEntities”, SpawnEnts )

function Spin()
for k,v in pairs(bubble) do
if (v:IsValid()) then
v:SetAngles(v:GetAngles() + Angle(0,3,0))
hook.Add(“Tick”,“Spinner”, Spin)


I’m clueless now, so if someone could please help, that would be very appreciated.

Get rid of the “for k, v in pairs” part. You cannot loop through an entity, only tables can be used with pairs(). Then just replace the v with bubble. Finally, get rid of the local before bubble so that the other functions can access it. It is out of their scope.

Thanks :), that worked. Stupid mistakes by me D:

its better to keep the local and use self.Entity instead

You could always keep the k,v and instead of “bubble” do ents.FindByClass(“entity1”)
or not because im 5 years late

wtf is with all the bumping today, I saw already a 6 year old thread wich was bumped, can a mod like, lock those?

Some peoples facepunch browsing starts at