You can write your topic however you want, but you need to answer these questions:
-
Trying to replicate vfx that I’ve made to all clients using :FireAllClients()
-
I’ve tried lots of methods and none show up. They are only shown on my screen
Currently I have 3 different scripts to try and replicate effects. A Client replicator which manages User Input Service, a module script where effects are managed and a server handler which manages damage,hitboxes and replicating effects to all clients.
Here are snippets of each.
Client replicator
local Abilities = {
["Moveset 1"] = {
"Punch",
"Dash",
"Rush",
}
}
local PlrStats = game.Players.LocalPlayer:WaitForChild("PlrStats")
local PlayerAbility = PlrStats:WaitForChild("Normal")
local UIS = game:GetService("UserInputService")
local FXRemote = game.ReplicatedStorage:WaitForChild("FXRemote")
local EffectsMod = require(script:WaitForChild("Effects"))
local debounce = false -- debounce variable
UIS.InputBegan:Connect(function(input, IsTyping)
if not IsTyping and not debounce then
debounce = true
local Char = game.Players.LocalPlayer.Character --or game.Players.LocalPlayer.CharacterAdded:Wait()
if input.KeyCode == Enum.KeyCode.One then
handleAbility(1, Char)
elseif input.KeyCode == Enum.KeyCode.Two then
handleAbility(2, Char)
elseif input.KeyCode == Enum.KeyCode.Three then
handleAbility(3, Char)
elseif input.KeyCode == Enum.KeyCode.Four then
handleAbility(4, Char)
elseif input.KeyCode == Enum.KeyCode.Five then
handleAbility(5, Char)
elseif input.KeyCode == Enum.KeyCode.Six then
handleAbility(6, Char)
end
wait(0.5)
debounce = false
end
end)
--end)
function handleAbility(abilityIndex, Char)
for i,v in pairs(Abilities) do
if PlayerAbility.Value == i and v[abilityIndex] then
local Ability = v[abilityIndex]
print(Ability)
local char = game.Players.LocalPlayer.Character
local isStunned = char:GetAttribute("Stunned")
if isStunned then
return -- If already stunned, do nothing
else
char:SetAttribute("Stunned", true)
local stunCheck = game.ReplicatedStorage.StateHandler
stunCheck:FireServer()
FXRemote:FireServer(Ability, Char)
EffectsMod[Ability](Char)
delay(2, function()
char:SetAttribute("Stunned", false)
end)
end
end
end
end
FXRemote.OnClientEvent:Connect(function(abilityName, targetChar)
if EffectsMod[abilityName] then
EffectsMod[abilityName](targetChar)
else
warn("Effect not found: " .. abilityName)
end
end)
Module Script
local TS = game:GetService("TweenService")
local FXRemote = game.ReplicatedStorage.FXRemote
local module = {
["Red"] = function(TargetChar)
local Char = TargetChar
local hum = Char.Humanoid or Char:WaitForChild("Humanoid")
local RArm = Char:FindFirstChild("Right Arm")
local HumRP = Char:FindFirstChild("HumanoidRootPart")
hum:LoadAnimation(script.Animations.Limitless.Red):Play()
local vfx = script.VFX.Limitless.Red:Clone()
vfx.Parent = game.Workspace
vfx.CFrame = RArm.CFrame * CFrame.new(0,-1,0) * CFrame.Angles(math.rad(0),math.rad(0),math.rad(0))
local weld = Instance.new("WeldConstraint")
weld.Part0 = vfx
weld.Part1 = RArm
weld.Parent = vfx
wait(1)
local ServerRemote = game.ReplicatedStorage.FXRemote
ServerRemote:FireServer("Punch")
Server Script
local remote = game.ReplicatedStorage.ServerRemote
local FXRemote = game.ReplicatedStorage:WaitForChild("FXRemote")
remote.OnServerEvent:Connect(function(Player,Ability, Special)
if Ability == "Punch" then
if PlayerAbility.Value == "Limitless" then
local Char = Player.Character
local HumRP = Char.HumanoidRootPart
FXRemote:FireAllClients(Char)
end
end
end)