After I noticed that particles aren’t centered while emitting (I was directly adding the emitters to the Player Torso), I opted to use an attachment instead.
Strange thing is that, the particles just refuse to appear. The sound that plays in this script does work, however.
Anybody could give any advice?
local particle2 = game.ReplicatedStorage.WepPar:FindFirstChild(par)
local partchild = particle2:GetChildren()
local attachment = Instance.new("Attachment", data.Torso)
for i = 1, #partchild do
local clone = partchild[i]:Clone()
clone.Parent = attachment
local emitime = clone:GetAttribute("emit")
clone:Emit(emitime)
if clone:FindFirstChild("Sound") then
clone.Sound:Play(1)
end
end
Strangely, it works when the particles were directly applied to the torso, but not if it is an attachment - though, that just made the particle effects appear off center lol
I think particle emitters require a surface area to emit from, so a point attachment wouldn’t have this.
You could try amending the z-offset, emission direction etc of the emitter to fix the positioning.
Would that work for a player? I’ve had 2 iterations of this code already;
One created an invisiblle part at the player to produce the particle, then is destroyed. This, however, made the particle “Linger Behind” - aka it didn’t follow the player
The next one was the aforementioned attaching to torso
Does Offset work for moving objects? This is from ServerScriptService, FYI. Sorry if im asking a little too much here
That’s the really weird thing; The only way that would be possible is if the part itself was very small - which, in case of a humanoid torso, isn’t. The Official Documentation itself recommended the use of Attachments to rectify this issue. I’m pretty sure this wasn’t actually possible a few years ago, but was added after popular request.
You are completely right (lesson to self: check docs properly!).
The only thing I can think of then is that the attachment isn’t parenting to the part as expected.
Instead of: local attachment = Instance.new("Attachment", data.Torso)
Try:
local attachment = Instance.new("Attachment")
attachment.Parent = data.Torso
Instance | Roblox Creator Documentation
You could also try printing the attachments CFrame to make sure where it is.
Also a render stepped wait to ensure it is there before emitting.
Hope this helps.
Unfortunately, this was already tried; In Workspace, if you hovered over the player model, and selected the torso, you would be able to see the attachment on it (By extension, the emitters). It’s why the sound played works
The Actual full code is here; Hopefully someone could figure something out.
How it works is that another script would fire the event to this script (Particles when you hit the enemy, get hit etc), which finds the particles in ReplicatedStorage and places them in the target - either you or the hit target.
remote.Event:Connect(function(data, par)
local particle2 = game.ReplicatedStorage.WepPar:FindFirstChild(par)
local partchild = particle2:GetChildren()
local attachment = Instance.new("Attachment", data.HumanoidRootPart)
for i = 1, #partchild do
local clone = partchild[i]:Clone()
clone.Parent = attachment
local emitime = clone:GetAttribute("emit")
clone:Emit(emitime)
clone.Enabled = true
if clone:FindFirstChild("Sound") then
clone.Sound:Play(1)
end
end
task.wait(1)
local torsolist = data.HumanoidRootPart:GetChildren()
for i = 1,#torsolist do
if torsolist[i].Name == "Attachment" then
torsolist[i]:Destroy()
end
end
end)