Re: I need help with a script I am making
Edit: Here.
Code:
function Create(self)
self.mapwrapx = SceneMan.SceneWrapsX;
self.maxlazerlength = 500;
self.particlespacing = 10;
self.parspeed = 10 -- SPEED OF PARTICLE HERE
self.weaponname = "Justice";
local curdist = 50;
for i = 1,MovableMan:GetMOIDCount()-1 do
gun = MovableMan:GetMOFromID(i);
if gun.PresetName == self.weaponname and gun.ClassName == "HDFirearm" and (gun.Pos-self.Pos).Magnitude < curdist then
actor = MovableMan:GetMOFromID(gun.RootID);
if MovableMan:IsActor(actor) then
self.parent = ToActor(actor);
self.parentgun = ToHDFirearm(gun);
local terrcheck = Vector(0,0);
local terrainray = SceneMan:CastStrengthRay(self.parentgun.MuzzlePos,Vector(i*10,0):RadRotate(self.parent:GetAimAngle(true)),0,terrcheck,4,0,true)
if terrainray == true then
self.lazerlength = math.floor(SceneMan:ShortestDistance(self.parentgun.MuzzlePos,terrcheck,self.mapwrapx).Magnitude/self.particlespacing)
else
self.lazerlength = math.floor(self.maxlazerlength/self.particlespacing);
end
for i = 1, self.lazerlength do
self.lazerpar = CreateMOPixel("Justice Shot"); -- CHANGE THIS TO YOUR PARTICLE
self.lazerpar.Pos = self.parentgun.MuzzlePos + Vector(i*self.particlespacing,0):RadRotate(self.parent:GetAimAngle(true));
self.lazerpar.Vel = Vector(self.parspeed,0):RadRotate(self.parent:GetAimAngle(true));
MovableMan:AddParticle(self.lazerpar);
end
end
end
end
end
self.maxlazerlength and self.particlespacing in the create funtion are the things to change.