I want to stop prevent the issue where the vfx is no longer showing up…
Issue : the vfx is not showing up after 1 minute about.
Solutions, I have tried : debugging to know if the code is the problem.
- its emitting, its clonning, its anchored. I dont have enough experience to pin point more debugging.
Review the video you will see the issue:
Module Script BlockHandler
local BlockHandler = {}
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BridgeNet = require(ReplicatedStorage.Modules.BridgeNet2)
local SpeedManager = require(script.Parent.SpeedManager)
local Animations = ReplicatedStorage:WaitForChild("Animations")
local blockAnimation = Animations:WaitForChild("Fist"):WaitForChild("Blocking")
local isUserBlockingConnection = BridgeNet.ServerBridge("UserBlocking")
local playerAnimationTracks = {}
isUserBlockingConnection:Connect(function(player, isBlocking)
local character = player.Character or player.CharacterAdded:Wait()
local isDashing = character:GetAttribute("IsDashing")
local isPunching = character:GetAttribute("IsPunching")
if isDashing or isPunching then
return
end
character:SetAttribute("IsBlocking", isBlocking)
if isBlocking then
character:SetAttribute("PerfectBlock", true)
delay(0.1, function()
if character:GetAttribute("IsBlocking") then
character:SetAttribute("PerfectBlock", false)
end
end)
character:SetAttribute("BlockCount", 0)
else
character:SetAttribute("PerfectBlock", false)
character:SetAttribute("BlockCount", nil)
end
local humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid then return end
local animator = humanoid:FindFirstChildOfClass("Animator") or Instance.new("Animator", humanoid)
if not playerAnimationTracks[player] then
playerAnimationTracks[player] = animator:LoadAnimation(blockAnimation)
end
local animationTrack = playerAnimationTracks[player]
if isBlocking then
animationTrack:Play()
SpeedManager:ApplyEffect(character, "block")
else
animationTrack:Stop()
SpeedManager:ApplyEffect(character, "normal")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
playerAnimationTracks[player] = nil
end)
return BlockHandler
VFX Emitting from another module script
local function BlockParticles(humanoid)
print("block")
local character = humanoid.Parent
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
if not humanoidRootPart then return end
local clonedBlockVFX = BlockVFX:Clone()
clonedBlockVFX.Position = humanoidRootPart.Position
clonedBlockVFX.Anchored = true
clonedBlockVFX.CanCollide = false
clonedBlockVFX.Parent = character
for _, descendant in pairs(clonedBlockVFX:GetDescendants()) do
if descendant:IsA("ParticleEmitter") then
local emitCount = descendant:GetAttribute("EmitCount") or 50
task.delay(0, function()
descendant:Emit(emitCount)
print("emitB")
end)
end
end
task.delay(2, function()
clonedBlockVFX:Destroy()
end)
end
local function PerfectBlockParticles(humanoid)
print("perfectblock")
local character = humanoid.Parent
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
if not humanoidRootPart then return end
local clonedBlockVFX = PerfectBlockVFX:Clone()
clonedBlockVFX.Position = humanoidRootPart.Position
clonedBlockVFX.Anchored = true
clonedBlockVFX.CanCollide = false
clonedBlockVFX.Parent = character
for _, descendant in pairs(clonedBlockVFX:GetDescendants()) do
if descendant:IsA("ParticleEmitter") then
local emitCount = descendant:GetAttribute("EmitCount") or 50
task.delay(0, function()
descendant:Emit(emitCount)
print("emitPB")
end)
end
end
task.delay(2, function()
clonedBlockVFX:Destroy()
end)
end
local function BlockBreakParticles(humanoid)
print("blockbreak")
local character = humanoid.Parent
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
if not humanoidRootPart then return end
local clonedBlockVFX = BlockBreakVFX:Clone()
clonedBlockVFX.Position = humanoidRootPart.Position
clonedBlockVFX.Anchored = true
clonedBlockVFX.CanCollide = false
clonedBlockVFX.Parent = character
for _, descendant in pairs(clonedBlockVFX:GetDescendants()) do
if descendant:IsA("ParticleEmitter") then
local emitCount = descendant:GetAttribute("EmitCount") or 50
task.delay(0, function()
descendant:Emit(emitCount)
print("emitBB")
end)
end
end
task.delay(2, function()
clonedBlockVFX:Destroy()
end)
end
-- this is the part that calls those functions
if hitHumanoid.Parent:GetAttribute("IsBlocking") == true and isAttackFromFront(hitHumanoid.Parent, player.Character.HumanoidRootPart.Position) then
local characterId = hitHumanoid.Parent:GetAttribute("UserId") or hitHumanoid.Parent.Name
if not processedCharacters[characterId] then
processedCharacters[characterId] = true
if hitHumanoid.Parent:GetAttribute("PerfectBlock") == true then
PerfectBlockParticles(hitHumanoid)
else
local blockCount = hitHumanoid.Parent:GetAttribute("BlockCount") or 0
blockCount = blockCount + 1
if blockCount >= 5 then
BlockBreakParticles(hitHumanoid)
hitHumanoid.Parent:SetAttribute("BlockCount", 0)
else
BlockParticles(hitHumanoid)
hitHumanoid.Parent:SetAttribute("BlockCount", blockCount)
end
end
return
end
end