I Have a weird bug where the effect doesn’t clone to the workspace and it never seems to emit.
i think the issue is the task.delay
if the vfx variable was listed outside of the function while i comment out the task.delay then it works as fine, not really sure why it could cause any issues.
local Fist = {}
local critSound = game:GetService("ReplicatedStorage").Sounds.CombatSound.Undodgeable
local dmg_per_tick = 0.2
local posture_per_tick = 0.2
local fistcritanim = game:GetService("ReplicatedFirst").Animations.Weapons.Fist.Crit.Critical
function Fist.Critical(plr,weapon)
local hum = plr.Character:WaitForChild("Humanoid")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local KanjiVfx = ReplicatedStorage:WaitForChild("Vfx")["Kanji effect"]:Clone()
KanjiVfx.Parent = workspace
KanjiVfx.Position = plr.Character.Head.Position
KanjiVfx.Attachment.ParticleEmitter:Emit(1)
critSound:Play()
task.wait(0.1)
local animtrack = hum:LoadAnimation(fistcritanim)
local playanimation = ReplicatedStorage.RemoteEvents.Other.PlayAnimation
animtrack:Play()
animtrack:AdjustSpeed(0.6)
animtrack:GetMarkerReachedSignal("FistCrit"):Connect(function()
print("Marker Reached")
end)
task.delay(4, function()
KanjiVfx:Destroy()
end)
end
return Fist
when you’re cloning the part, which is a good way of doing it, the part itself may be destroyed if its not anchored when cloned to the workspace, you should use welds to weld it the characters head when its cloned to the head, and then destroy the welds when youre done with the effect. With this you don’t need to move the attachments position only move the parts position to where the effect should be
local function WeldEffect(player: Player, effectPart: BasePart?, offsets)
local character = player.Character
local motor6D = Instance.new("Motor6D", effectPart)
motor6D.Part0 = player.Character:WaitForChild("Head")
motor6D.Part1 = effectPart
motor6D.C1 = CFrame.new(offsets.x, offsets.y, offsets.z)
end
could be a way of doing it, motor6d is optional welds work as well I’ve personally seen motor6d works well. In the future if you’re using a ragdoll system, the ragdoll system may break the motor6d so be wary of that
also if you’re using motor6d method, make sure you dont anchor the part youre cloning
The welding works however it still doesnt emit anything like the :Emit(1) doesnt do anything at all
local Fist = {}
local critSound = game:GetService("ReplicatedStorage").Sounds.CombatSound.Undodgeable
local dmg_per_tick = 0.2
local posture_per_tick = 0.2
local fistcritanim = game:GetService("ReplicatedFirst").Animations.Weapons.Fist.Crit.Critical
local function WeldEffect(player: Player, effectPart: BasePart?, offsets)
local character = player.Character
local motor6D = Instance.new("Motor6D", effectPart)
motor6D.Part0 = player.Character:WaitForChild("Head")
motor6D.Part1 = effectPart
motor6D.C1 = CFrame.new(offsets.x, offsets.y, offsets.z)
end
function Fist.Critical(plr,weapon)
local offsets = {
x = 0,
y = 0,
z = 0
}
local hum = plr.Character:WaitForChild("Humanoid")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local KanjiVfx = game:GetService("ReplicatedStorage"):WaitForChild("Vfx")["Kanji effect"]:Clone()
KanjiVfx.Parent = plr.Character:WaitForChild("Head")
WeldEffect(plr,KanjiVfx,offsets)
KanjiVfx.Attachment.ParticleEmitter:Emit(1)
critSound:Play()
task.wait(0.1)
local animtrack = hum:LoadAnimation(fistcritanim)
local playanimation = ReplicatedStorage.RemoteEvents.Other.PlayAnimation
animtrack:Play()
animtrack:AdjustSpeed(0.6)
animtrack:GetMarkerReachedSignal("FistCrit"):Connect(function()
print("Marker Reached")
end)
task.delay(10, function()
KanjiVfx:Destroy()
end)
end
return Fist
Check to make sure the effect is at the place of the vfx part, sometimes it might actually emit but somewhere away from the character or below them, if the effect part is under the head it should emit with no bugs, it might just be emitting somewhere further away from the player
then adjust it with the offsets argument in the function
hmm, I still think it might be an issue with the y offset of the motor6d weld, cause I had that pretty often even when I didnt think I did, but to make sure, take the effect part put it in the workspace, reference it in a script and try emitting the particle, maybe emit(1) count isn’t enough. Other than that I’m not sure
One thing I want to say first: Move the variables for ReplicatesStorage and ServerStorage outside of the function. Having to make reference to them in the middle of a function is pointless.
Moving on, use game.Debris to set a delay for the KanjiVfx instance to be destroyed.
When you emit the particle emitter, try a higher number, and maybe try increasing the size incase the head is blocking it.
In the animtrack:GetMarkerReachedSignal function, make it a :Once instead of a :Connect
Lastly, make reference to the KanjiVfx object outside of the function aswell, and clone it in the function.
The final thing I want to get out of the way is that you don’t need to clone the Part itself, and instead clone the attachment in the part (the attachment that has the particle emitter), and parent it to the head.
This is a lot of backseat driving I just did but personally I think your function needs some refining. Hope you have fun in your project though
No problem! Considering you set it as the solution, I’ll assume that it had worked. Another thing: When making VFX, try scaling them to a character model so that you don’t accidentally make an incredibly small one. Glad I could actually get my first Solution