Hey Pro Devs Of Robloxia,
I am new to vfx and stuff and I made some particles effects and I want them to be on other npc or player’s character when I damage them with sword, I tried one script here but it didn’t work:
script.Parent.Touched:Connect(function(hit)
local RS = game.ReplicatedStorage
local Spark = RS.Spark.SparkFX:Clone()
local Circle = RS.EnergyCircle.EnergyCircleFX:Clone()
Spark.Parent = hit.Parent.HumanoidRootPart
Spark.Position = hit.Parent.HumanoidRootPart.Position
Circle.Parent = hit.Parent.HumanoidRootPart
Circle.Position = hit.Parent.HumanoidRootPart.Position
end)
Can someone help me figure out this, any sort of help is appreciated!
EDIT: I almost forgot to tell that I added the particles inside attachments!!
Assuming that SparkFx and CircleFx are particles. Go to there properties and set there rate to 0 and than then create an attachment and instance the particles inside of them and then copy and paste this new code with the new names of the new instances which will be quoted in []
local RS = game.ReplicatedStorage
script.Parent.Touched:Connect(function(hit)
if hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
local SparkAttachment = RS["NAME OF ATTACHMENT"].SparkFX:Clone()
local CircleAttachment = RS["NAME OF ATTACHMENT"].EnergyCircleFX:Clone()
game:GetService("Debris"):AddItem(SparkAttachment,2)
game:GetService("Debris"):AddItem(CircleAttachment,2)
SparkAttachment.Parent = hit.Parent.HumanoidRootPart
CircleAttachment.Parent = hit.Parent.HumanoidRootPart
for i,v in pairs(SparkAttachment:GetChildren()) do
if v:IsA("ParticleEmitter") then
v:Emit(10)
end
end
for i,v in pairs(CircleAttachment:GetChildren()) do
if v:IsA("ParticleEmitter") then
v:Emit(10)
end
end
end
end)
They may be errors in this code as this is my first time helping someone on the Dev Forums but just reply back to me if you can’t figure it out yourself. I also suggest you add a debounce to this too as the particles could emit mutiple times.