Hello! So I would like to find out how to make parts spin diagonally around a character in different directions. Something a bit like this, if anyone could help it would be much appreciated.
Have a go at this, it’s far from ideal, or even remotely the best way to do it, but at least it gives you some idea of the mathematics involved. Just put this in a LocalScript parented under StarterCharacterScripts.
game.Lighting.ClockTime = 0;
math.randomseed(os.clock());
local parts = {};
local seeds = {};
local function makePart(pos)
local part = Instance.new("Part");
part.Size = Vector3.new(1,1,1);
part.Shape = Enum.PartType.Ball;
part.Color = Color3.new(0.5,1,0.5);
part.Parent = game.Workspace;
part.CanCollide = false;
part.Anchored = true;
part.Material = Enum.Material.Neon;
part.Position = pos + Vector3.new(math.random(),math.random(),math.random());
local light = Instance.new("PointLight",part);
light.Color = part.Color;
local emitter = Instance.new("ParticleEmitter",part);
emitter.VelocityInheritance = Vector3.new(-50,0,-50);
emitter.Rate = 200;
emitter.Drag = 0.1;
emitter.EmissionDirection = "Bottom";
emitter.Texture = "rbxassetid://7412493185";
emitter.Lifetime = NumberRange.new(0.3);
emitter.Color = ColorSequence.new(part.Color);
emitter.Transparency = NumberSequence.new(0,1);
table.insert(parts,part);
table.insert(seeds,math.random(-20,20)/10);
end
local start = tick();
local radius = 3;
local fw = -1;
local fv = 0.01;
local hrp = script.Parent:WaitForChild("HumanoidRootPart",3);
for i=0, 5 do
makePart(hrp.Position);
end
while true do
local t = tick()-start;
for i, part in pairs(parts) do
local x = (radius-seeds[i])*math.cos(t*i);
local z = (radius-seeds[i])*math.sin(t*i);
part.Position = hrp.Position + Vector3.new(x,seeds[i]+fw,z);
part.PointLight.Brightness = 5*math.random();
part.ParticleEmitter.Size = NumberSequence.new(math.random(),0.5);
fw += fv;
if fw > 3 or fw < -2 then
fv *= -1;
end
end
wait();
end
Sorry forgot you said different directions, play around with this part for different effects, this one goes opposite directions.
local x = (radius-seeds[i])*math.cos(t*i);
local z = (radius-seeds[i])*math.sin(t*i);
part.Position = hrp.Position + Vector3.new(i*seeds[i]*x,seeds[i]+fw,z);
This is cool too:
local x = fw*(radius-seeds[i])*math.cos(t*i*seeds[i]);
local z = fw*(radius-seeds[i])*math.sin(t*i*seeds[i]);
part.Position = hrp.Position + Vector3.new(seeds[i]*x,seeds[i]+fw,seeds[i]*z);
Here’s an example of it working. It uses a lot of math.random() so essentially it will be very different every time you run it. If you run it and find a nice motion you want to keep, just break into the code and copy the vales stored in the seeds
table which is created here table.insert(seeds,math.random(-20,20)/10)
.
1 Like