You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
i want to achieve this particle to emit when the player equips a sword
- What is the issue? Include screenshots / videos if possible!
the particle doesnt emit. i have a module, a local script and a serverscript.
My Module Script:
local module = {}
--||Services||--
local Debris = game:GetService("Debris")
--
function module.EmitEffect(effect,cframe,destroyTime)
local effect = effect:Clone()
effect.Parent = workspace.VFX
effect.CFrame = cframe
for i, v in pairs(effect:GetDescendants()) do
if v:IsA("ParticleEmitter") then
v:Emit(v:GetAttribute("EmitCount"))
end
end
Debris:AddItem(effect,destroyTime)
end
return module
My Local Script:
--||Services||--
local RS = game:GetService("ReplicatedStorage")
--||Folders||--
local Events = RS.Events
local Modules = RS.Modules
--||Modules||--
local CombatEffectsModule = require(Modules.Combat.EffectsModule)
-----------------------------------------------------------------------------------------
Events.VFX.OnClientEvent:Connect(function(action,...)
if action == "CombatEffects" then
local effect,cframe,destroyTime = ...
CombatEffectsModule.EmitEffect(effect,cframe,destroyTime)
end
end)
And lastly, my normal script.
The line where i emit the particle is on line 84.
--||Services||--
local Players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")
local SoundService = game:GetService("SoundService")
local Debris = game:GetService("Debris")
--||Folders||--
local Models = RS.Models
local WeaponModels = Models.Weapons
local WeaponsWelds = script.Welds.Weapons
local Events = RS.Events
local AnimationsFolder = RS.Animations
local WeaponsAnimations = AnimationsFolder.Weapons
local WeaponsSounds = SoundService.SFX.Weapons
local ModulesFolder = RS.Modules
--||Events||--
local WeaponsEvent = Events.WeaponsEvent
--||Objects||--
local Welds = {}
--||Modules||--
local SoundsModule = require(ModulesFolder.Combat.SoundsModule)
--||Animations||--
local EquipAnims = {}
local UnequipAnims = {}
local IdleAnims = {}
--||Values||--
local EquipDebounce = {}
-----------------------------------------------------------------------------------------
Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local torso = char.Torso
--
char:SetAttribute("Equipped", false)
char:SetAttribute("CurrentWeapon", "Sabre")
--
local currentWeapon = char:GetAttribute("CurrentWeapon")
--
local Weapon = WeaponModels[currentWeapon]:Clone()
Weapon.Parent = char
Welds[plr] = WeaponsWelds[currentWeapon].IdleWeaponWeld:Clone()
Welds[plr].Parent = torso
Welds[plr].Part0 = torso
Welds[plr].Part1 = Weapon
end)
end)
Players.PlayerRemoving:Connect(function(plr)
if Welds[plr] then
table.remove(Welds, table.find(Welds, Welds[plr]))
end
end)
--
WeaponsEvent.OnServerEvent:Connect(function(plr, action)
local char = plr.Character
local hum = char:WaitForChild("Humanoid")
local torso = char.Torso
local rightArm = char["Right Arm"]
local currentWeapon = char:GetAttribute("CurrentWeapon")
--
if action == "Equip/Unequip" and not char:GetAttribute("Equipped") and not EquipDebounce[plr] then -- Equipping the weapon
EquipDebounce[plr] = true
Events.VFX:FireAllClients("CombatEffects", RS.Effects.Combat.Blood, char.Torso.CFrame, 3)
SoundsModule.PlaySound(WeaponsSounds[currentWeapon].Main.Equip, torso)
IdleAnims[plr] = hum.Animator:LoadAnimation(WeaponsAnimations[currentWeapon].Main.Idle)
EquipAnims[plr] = hum.Animator:LoadAnimation(WeaponsAnimations[currentWeapon].Main.Equip)
EquipAnims[plr]:Play()
EquipAnims[plr]:GetMarkerReachedSignal("Weld"):Connect(function()
Welds[plr].Part0 = rightArm
Welds[plr].C1 = WeaponsWelds[currentWeapon].HoldingWeaponWeld.C1
end)
EquipAnims[plr]:GetMarkerReachedSignal("Equipped"):Connect(function()
IdleAnims[plr]:Play()
char:SetAttribute("Equipped", true)
EquipDebounce[plr] = false
end)
elseif action == "Equip/Unequip" and char:GetAttribute("Equipped") and not EquipDebounce[plr] then -- Unequipping the weapon
EquipDebounce[plr] = true
SoundsModule.PlaySound(WeaponsSounds[currentWeapon].Main.Unequip, torso)
IdleAnims[plr]:Stop()
UnequipAnims[plr] = hum.Animator:LoadAnimation(WeaponsAnimations[currentWeapon].Main.Unequip)
UnequipAnims[plr]:Play()
UnequipAnims[plr]:GetMarkerReachedSignal("Weld"):Connect(function()
Welds[plr].Part0 = torso
Welds[plr].C1 = WeaponsWelds[currentWeapon].IdleWeaponWeld.C1
end)
UnequipAnims[plr]:GetMarkerReachedSignal("Unequipped"):Connect(function()
char:SetAttribute("Equipped", false)
EquipDebounce[plr] = false
end)
end
end)