A client can kill a npc and it will replicate to the server

I have an NPC and I tested Humanoid:TakeDamage in the command bar. For some strange reason when the NPC dies on the clients side it replicates to the server. I don’t even know what could be causing this as I don’t have any remote events that do damage through the server.

I have even tested it on an empty server with no scripts and still shows the same results.

2 Likes

Most things like health are managed on the client meaning any changes there occur on the server

1 Like

That shouldn’t be the case. The server would not be able to see the damage that the client gives it.

client:
image

server:
image

1 Like

No like i said the data for your player is managed on the client, health is one of them, there isnt a very easy way of doing this apart from having a numbervalue called health in the character and a script to set the health to the number on the server then changing that value instead

1 Like

I highly recommend you use:

RemoteEvent

1 Like

Even with a remote event an exploiter can just execute a :TakeDamage script

2 Likes

Oh, wait, my bad. I think I read that wrong.

1 Like

like i said make your own server value like this:

local runService = game:GetService("RunService")

runService.Heartbeat:Connect(function()
script.Parent.Humanoid.Health = script.Parent.Health.Value
end)
1 Like

I think you should try setting the network owner of the NPC to nil so it can’t be changed by the client.

NPC.HumanoidRootPart:SetNetworkOwner(nil)
2 Likes

It mite b due to network ownership. Try changing it to nil.

2 Likes

Health does not replicate from the client to the server, as doing so would create issues, such as exploiters being able to set their health insanely high.

Client:
Screen Shot 2021-08-09 at 8.16.07 AM

Server:
Screen Shot 2021-08-09 at 8.15.57 AM

Why not just have the server take care of the health entirely?
The client cannot tamper with their own health through exploits, it would just look like healthbar gucci.

That’s exactly what’s happening, actually

How about you constantly change the humanoids health at the first priority so even if the exploiter does change the health it will go right back

That’s not really necessary, as the second the server changes the client’s health, the client will replicate that

I can confirm this behaviour.
My NPCs have :TakeDamage() dealt by the server not the client.

If the client changes the NPC Health to 0, it will not die.
However, if the NPC is then damaged on the server, it dies on the client and server.
This happens even if the NPC still has >0 health on the server.

Arc_Cosine’s suggestion fixed this behaviour.

5 Likes