localworld=require(shared.world)localcomponents=require(shared.components)localalive,energy=components.alive,components.energyworld.query(alive,energy)(function(entity,clean)-- regenerate 1 energy every secondlocalloop=task.spawn(function()whiletask.wait(1)dolocalenergy=world.get(entity,energy)world.insert(entity,math.min(100,energy+1))endend)-- cleanup coroutine on removeclean(function()task.cancel(loop)end)end)returnnil
Create an entity
Now, create an entity with some initial energy and the alive component