Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Damage scripts not working on parts replicated to all clients?

Asked by 5 years ago
Edited 5 years ago

I've created a project which is based mostly upon projectiles - at first, I had the server handle literally everything, and that caused all the projectiles and jazz to lag, so I've decided to have all the parts managed clientside.

In this scenario, I've created a RemoteEvent.OnClientEvent function, which is called by a client firing a RemoteEvent to fire this ClientEvent. The visual part is fine, and the projectile lag I had before is completely gone, but now the bullets do no damage at all? I've no clue why, as the script IS in the part, all values ARE returning, but it just doesn't want to do damage.

I've guessed that it was because the parts don't actually exist on the server, but how can I overcome this problem and make these parts do OnTouch Damage?

Here's a faint idea of the code i've been using;

-- Inside the Client Event (In a localscript in StarterGui)
    local ball = Instance.new("Part")
    ball.Name = "BlastBullet"
    Resources.MarkInfo(set, "BlastBullets", dmg, script.BlastBulletDamage, ball)
-- The Server Event
bb.OnServerEvent:Connect(function(player,set, dmg)
    local spell = game.ReplicatedStorage:WaitForChild("BlastBullets")
    spell:FireAllClients(player,set, dmg)
end)
-- The LocalScript which fires the server event
local ev = game.ReplicatedStorage:WaitForChild("BlastIsFat")
ev:FireServer(Settings, Resources.CalculateDamage1(Settings))

I'll start explaining from topdown, as it makes sense.

The client event is basically creating a part called BlastBullet, i've left out the details of shaping the parts because nobody wants to see that. What 'Resources.MarkInfo' does is take the Settings table, which was passed through from the other localscript, and basically just clones the damage script(a server script), add's values such as 'Creator', 'Damage', and all of that jazz, and enables it.

The server event is literally the only way I could think of to pass the information.

The localscript, which is the script containing all mana checks, damage calculations, animations, etc, fires that server event, and passes all the information in that script to the server, which, using FireAllClients(), replicates everything to every client.

Basically, the parts don't exist on the server and I don't know how to make those parts actually to OnTouch damage.

I also don't want to use RayCasting, because, well, they're projectiles. If any more information is needed, let me know! My discord is evil#7042, but i'll still be spam refreshing this page.

0
Parts that are local do not replicate their Touched events to the server. Therefore, damage does not save to the server. Using a RemoteEvent to send the part over is still going to keep the part local; whatever end created the part will keep the status of the part as relative to that end. DeceptiveCaster 3761 — 5y
0
If your looking to do that "laggy" stuff on the client, simply do all of the math and calculations ETC on the client, and fire it all over to the server. Because there is no good way to replicate something from one client to all of the other clients without it first going through the server. mc3334 649 — 5y

Answer this question