Best way to damage player?

I made a remote event that whenever you touch a part… You will lose 10 hp. It works, but I am wondering if exploiters can exploit this or is it secure?

--Client-Side: 

local dmgPart = game.Workspace.DamagePart
local dmgEvent = game:GetService("ReplicatedStorage").DamageEvent

dmgPart.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        dmgEvent:FireServer(hit)
    end
end)


--Server-Side:

local dmgEvent = game:GetService("ReplicatedStorage").DamageEvent

dmgEvent.OnServerEvent:Connect(function(player, hit)
    hit.Parent:FindFirstChild("Humanoid").Health -= 10
end)

Any response is appreciate! :smiley:

2 Likes

What’s the point of firing an event? Can’t you just damage them with a server script?

1 Like

True, but I heard it’s a lot better and reduces lag with a remote event

1 Like

I don’t commonly have issues with kill bricks lagging, so damaging on the server is a better way to handle this. Keep in mind exploiters have the ability to use FireServer and could probably spam this event

local dmgPart = script.Parent -- Inside the part

dmgPart.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") ~= nil then
        local char = hit.Parent
        char:WaitForChild('Humanoid').Health -= 10
    end
end)
1 Like

you can also use Humanoid:TakeDamage(10) but i don’t know witch is better

Hackerman changes “Hit” to a in-game players character. U just killed an innocent person.
Hackermans can exploit this, Just leave it on the server in my opinion.

The

.Touched

Event relies on the Clients FPS, The server has a base and tries to maintain a constant heartbeat so this event is fired securely. If a client has like 15 FPS. You aint going to get that .Touched event. So its unreliable depending on the device. - Far fetched but yeah. Just leave it on the server.

2 Likes

If exploiters could take advantage of FireServer then what is the point of even having the function???

1 Like

To be honest, exploiters can take advantage of anything these days. It’s nothing to worry about, all developers have to deal with it

1 Like