Im using a system i think would save quite a lot of server memory for combat. Lets say only you can fight, so only you have a local script (A) that has the triggers for abilities and cooldowns and all. I know the process can seem pretty long but this local script (A) sends info to a script inside it, that also redirects the info to another local script (B) that, this time, all players have. this local script (B) deals w the visual effects, sounds and hit-detection. On hit it, it does a few checks and fires a remote event to deal damage on the server side.
Enough of that, i’ve used this method quite a lot of times and it works very smoothly but seems to stutter when i’m not fighting dummies (when fighting other players)
Well let’s just stick to the particle issue for now and i’ll try to figure out the rest on my own. Im using particle:Emit(n) to emit a bunch of particles at once when the “OnHit” function is triggered.
This seems to work fine for the person who’s performing the abilities, but it doesnt show for others.
The system intends to show these particles and vfx and play sounds for every client, just not on the server (things like knockback and damage aside), and all the scripts are located in StarterCharacterScripts
heres the local script (A) (only the important parts)
uis.InputBegan:Connect(function(input, gameProcessed)
local attackAnim = plrHum:LoadAnimation(script.Attack1)
attackAnim:Play()
script.Call:FireServer(player, anim) -- fires to a remote event that sends the info to local script (B)
end)
same for local script (B)
game.ReplicatedStorage.CombatEvent.OnClientEvent:Connect(function(callingPlayer, anim)
AbilityHitbox.Touched:Connect(function(hit)
if hum and not humanoidsThatHaveBeenHit[hum] and hum.Health > 0 then
script.DamageEvent:FireServer(hum, callingPlayer, anim) -- also contains knockbacks
particle:Emit() -- this is only showing for the "calling player" who is the one casting the ability
end
end)
end)
the “Local script (B)” is in everyone’s StarterCharacterScripts, its main job is to show vfx. “Local script (A)” is what triggers the abilities
This is probably only running on the client and not running for everyone.
To figure this out try and find where it stops working.
Try putting a print after
AbilityHitbox.Touched:Connect(function(hit)
and see if it runs for all clients.
Keep doing this in different places till you find where it is not running
This did actually solve an issue, knockbacks werent applying in the server script, which was because of an object that i assumed existed, but it wasnt actually there. i’ve done lots of tweaks that i actually dont remember what i did but i ended up adding a condition to the damage event firing that goes
if callingPlayer == game.Players.LocalPlayer then
script.Damage:FireServer(hum, callingPlayer, anim, game.Players.LocalPlayer.Name)
end
particle:Emit()
i’ll edit this once my brain is braining again sorry wanted to update as soon as i could
ive always been questioning why the damage isnt applying as many times as there are players in the server but didnt give it much thought cause yes it was “working” . Now it makes sense and this just changes lots of things. Thank u for ur help @FroDev1002