I have this weird problem that I’ve been stuck on for hours. I have this VFX that emits properly when you emit it in studio. But during playtesting, the emitter seems to be emitting backwards, which is not supposed to be happening. Please refer to the videos.
Here is my code:
local Debris = require(game.ReplicatedStorage.Modules.Debris)
local Assets = game.ReplicatedStorage.Assets
local function Emit(Parent)
for _, instance : Instance in pairs(Parent:GetDescendants()) do
if instance:IsA("ParticleEmitter") then
task.delay(instance:GetAttribute("EmitDelay"), function()
instance:Emit(instance:GetAttribute("EmitCount"))
end)
end
end
end
local function AdjustVelocity(LinearVelocity, GeneralVelocity, Life)
LinearVelocity.VectorVelocity = GeneralVelocity
task.delay(Life, function()
LinearVelocity.VectorVelocity = Vector3.new(0, 0, 0)
end)
end
return function(Owner)
local RootPart = Owner.HumanoidRootPart
for _, Attachment in pairs(script.Combo:GetChildren()) do
local New = Attachment:Clone()
New.Parent = RootPart
Debris:AddItem(New, 5)
Emit(New)
end
local Attachment = Instance.new('Attachment', RootPart)
local LinearVelocity = Instance.new('LinearVelocity', Attachment)
LinearVelocity.MaxForce = 999999
LinearVelocity.VectorVelocity = Vector3.new(0, 0, 0)
LinearVelocity.Attachment0 = Attachment
local GeneralVelocity = RootPart.CFrame.LookVector * 46
local Run = {
{
Time = 0.3;
Callback = function()
AdjustVelocity(LinearVelocity, GeneralVelocity, 0.15)
end,
};
{
Time = 0.68;
Callback = function()
AdjustVelocity(LinearVelocity, GeneralVelocity, 0.1)
end,
};
{
Time = 0.2;
Callback = function()
AdjustVelocity(LinearVelocity, GeneralVelocity, 0.1)
end,
};
{
Time = 1;
Callback = function()
LinearVelocity:Destroy()
end,
};
}
for _, ToRun in pairs(Run) do
task.wait(ToRun.Time)
ToRun.Callback()
end
end
ANOTHER NOTE
I removed the velocity and it seems to be working fine 90% of the time. However, when I hold down a movement key (ex. WASD), it breaks again… (The thing is, the velocity is essential… so I cannot remove it)
This is probably because of the player animations.
In studio, the rig was completely non-moving, while in playtesting the animations were causing the particles to emit in the back as the sword was being swung around back there.
I agree that it could be due to player movement, but I am not sure how I would go about fixing this. The movement is essential to the ability itself. Can you give me an idea on how you would fix it?
Nope, not at all. There is nothing in my script that rotates the attachments. I also checked during playtesting by using a loop that prints out attachment orientation.
I appreciate your patience. Thank you for trying to assist me! If I don’t resolve this problem, I’ll probably resort to an alternative. (mesh-based VFX flipbooks) Once again, thank you!
Yeah I have the same issue, I have no rotation or cframe change, even while standing still i have a 180 degree slash that is emitting randomly. Did anyone find this solution?
Whether it’s a part, attachment or anything that has a CFrame it copies that exact value of the HumanoidRootPart and sometimes the HumanoidRootPart has negative values in x and z even if it’s -0 it can break. In my case I was using a Part that copied the HumanoidRootParts CFrame then put the attachment in the Part and emitted and sometimes it would emit backwards. To Stop this I’d make sure only the Y value changes instead of the x and z values (positive values only). For example for me I did this
local _,y,_ = HumanoidRootPart.CFrame:ToOrientation()
Part.CFrame = CFrame.new(HumanoidRootPart.Position) * CFrame.Angles(0,y,0)