Hello! I would please like some help with some code of mine:
I am making a gas that duplicates itself but the problem is it does it only once and I can’t seem to find a reason why.
For now I only have it going on one direction, but later on it will also check if it can move, on all four directions and all of that stuff, but I can’t seem to get it to work.
Here’s the code:
AddCSLuaFile() DEFINE_BASECLASS( "base_anim" ) ENT.PrintName = "SCP-008 Gas1" ENT.Author = "ubre" ENT.Category = "SCP-RP" ENT.Spawnable = true ENT.AdminOnly = true local Speed = 5 //Seconds function ENT:Initialize() self:SetModel("models/hunter/blocks/cube025x025x025.mdl") self:SetColor(Color(0,0,0,0)) end function ENT:Draw() return end local Emitter if (CLIENT) then Emitter = ParticleEmitter(vector_origin) end ENT.Created = false ENT.Make = CurTime() + Speed function ENT:Think() if(SERVER) then if(self.Created == false) then if(self.Make <= CurTime()) then self.Created = true local Clone = ents.Create("scp008gas1") Clone:SetPos(self:GetPos() + Vector(100,0,0)) end end end end if(SERVER) then return end //CLIENT ENT.NextFX = 0 local Fx = "particle/smokesprites_0004" function ENT:Think() if(Emitter) then local Smoke = Emitter:Add(Fx, self:GetPos()) if(self.NextFX <= CurTime()) then if (Smoke) then Smoke:SetVelocity(Vector(math.random(-10,10), math.random(-10,10), math.random(20,70))) Smoke:SetLifeTime(0) Smoke:SetDieTime(4) Smoke:SetStartAlpha(150) Smoke:SetEndAlpha(0) Smoke:SetStartSize(80) Smoke:SetEndSize(30) Smoke:SetAngleVelocity(Angle(3,0,0)) Smoke:SetColor(255,30,90,255) Smoke:SetCollide(true) self.NextFX = CurTime() + 0.75 end end end end
Now, if you guys also help me out with a question of mine I would be super grateful, I was also wondering why sometimes it looks like when I spawn a new cloud, it uses the same local variables of the ones I already spawned, so for example instead of waiting 5 seconds to spawn a new cloud, it will do it instantly, why does it do that?