I'm trying to make a punch script and I'm handling the OnTouched event in Localscript (this whole script is a localscript). Yes, I want to deal damage, but at the same time make the RemoteEvent secure and as server-sided as possible so exploiters cannot manipulate it. I cannot think of a way to do it, however.
local punchConnection
punchConnection = LeftHand.Touched:Connect(function(interacted)
-- Punch Variables were placed in an event to randomize them more. --
local PunchDamage_Range = math.random(4, 8) -- Randomized Range of Damages for Punch.
local PunchCritical = math.random() -- Chance of Critical Hit if Player hits another Player in the Head.
local interactedHumanoid = interacted:FindFirstChild('Humanoid') or interacted.Parent:FindFirstChild('Humanoid')
if interactedHumanoid ~= nil and interactedHumanoid ~= Humanoid and not Hit and Punching then
Hit = true
if interacted.Name == 'Head' and PunchCritical >= 0.85 then
-- N/A
else
-- Line where I want to do damage
end
wait(PunchCooldown)
Hit = false
punchConnection:Disconnect()
end
end)
Any ideas? If so, please help, thanks!

4 comments
Handle damage on the server and play animations on the client
I'm sorry, can you be a bit explicit in terms of my issue?
I'm gonna assume that youre gonna deal damage by having an event fired like: damageEvent:FireServer(PunchDamage_Range), what the person meant above is that make the calculations within a server script that would handle receiving the client request. There are many exploit problems with your script such as an exploiter firing off an event with the parameters of random players, but you can find a way
That's the issue I'm trying to avoid, a remote that can be fired off on players and the damage argument can be changed. Would I have to handle the OnTouched event on a server script?