Currently, I’ve written a combat script but all of it is on the client. I’m trying to rewrite part of it in a server script so that values such as damage or cooldown can not be changed by the client through exploits. I’m aware that I should use a RemoteEvent to communicate between server and client, but the issue is I’m unsure of what to do after that.
UIS.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == keybind then
newHitbox1:SetPoints(rightarm, {Vector3.new(0.5, 1, -0.5), Vector3.new(-0.5, 1, 0.5), Vector3.new(0.5, 0, 0.5), Vector3.new(-0.5, 0, -0.5)})
newHitbox2:SetPoints(leftarm, {Vector3.new(0.5, 1, -0.5), Vector3.new(-0.5, 1, 0.5), Vector3.new(0.5, 0, 0.5), Vector3.new(-0.5, 0, -0.5)})
newHitbox1.OnHit:Connect(function(hit, humanoid)
newHitbox1:RemovePoints(rightarm, {Vector3.new(0.5, 1, -0.5), Vector3.new(-0.5, 1, 0.5), Vector3.new(0.5, 0, 0.5), Vector3.new(-0.5, 0, -0.5)})
print("hit1")
humanoid:TakeDamage(25)
end)
newHitbox2.OnHit:Connect(function(hit, humanoid)
newHitbox2:RemovePoints(leftarm, {Vector3.new(0.5, 1, -0.5), Vector3.new(-0.5, 1, 0.5), Vector3.new(0.5, 0, 0.5), Vector3.new(-0.5, 0, -0.5)})
print("hit2")
humanoid:TakeDamage(25)
end)
newHitbox1:HitStart(1)
newHitbox2:HitStart(1)
end
end)
Here’s a snippet of my code. For example, I’d like to have :SetPoint
, :TakeDamage
, and :HitStart
all defined in a server script which then gets relayed to the client. If I’m not mistaken, this should make it impossible for the client to exploit, but please let me know if I’m mistaken and how I should go about ensuring that these values can’t be messed with!