Question for Client-Sided VFX

Update:
All of my attacks are client-sided VFX and I’m on my last set of attacks already nearing my release of the game but I encountered a problem:

The tools used to trigger the attacks have the local scripts under them. I tested a situation where player 1 has the tools and player 2 does not. It didn’t replicate as you might have expected.

So I placed the local scripts instead under the StarterCharacter (which will then be parented under the tool if the player acquires the tool) which worked! But, the problem is when the player dies, the scripts under him will stop (and reset) when he respawns. This results into some of the debris not being deleted fully since I have tweens before deleting them using the Debris Service inside the local script. So for player 1, the debris is still there but for player 2 it has been removed. Here’s a demonstration:

For now I will just make a debrisHandler on the StarterCharacter that will count how long the debris have been in the DebrisFolder and if it’s been there for an unusual amount of time, I will tween and delete it. If it can’t be tweened then I will add it to the debris service immediately.

In short, the code in my local scripts that handle the client-sided VFX stop and reset when the player respawns which halts any existing code being done by that local script

How to deal with this?

1 Like

Why don’t you put debrisHandler under StarterPlayerScripts?

1 Like

On top of that, I would put all the VFX scripts under StarterPlayerScripts.

I don’t know how your tools are set up, but here’s what I would do:

  1. In each of your VFX scripts, create a listener to a VFX creation remote event

  2. When the server receives an attack remote event, it fires all clients with the name of the VFX to create or some identifier for the attack started

  3. The VFX scripts receive the signal and the matching script creates the visual

2 Likes

Thanks! My initial hierarchy was

Tool
→ Local Script
->->Remote Event
->->-> Script

The above hierarchy works but the problem is with the replication if the player doesn’t have the tools, meaning they won’t have access to the scripts.

Placing the local scripts and the children under them in StarterCharacter also poses a problem of the codes breaking if the Character has respawned which resets the code even if it’s running.

So I now placed the Local Script in StarterPlayerScripts,
the remote event in ReplicatedStorage,
and the Server Script in ServerScriptService.

ParticleEmitters are rendered on the client, so whatever works best for you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.