I am doing hitboxes on client side then detecting targets on server side, I have already made a distance check so that exploiters can kill everyone around the map, but something that I worry about is how the player can just walk around in somone’s area and abuse the remote and hit players nearby without clicking. How do I prevent this?
CLIENT:
local function Hitbox(Damage, Long)
local R = Ray.new(StandModel:FindFirstChild("HumanoidRootPart").Position, StandModel:FindFirstChild("HumanoidRootPart").CFrame.lookVector * 100)
local IgnoreList = {LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()}
for i,v in pairs(workspace:GetDescendants()) do
if (v:IsA("Part") or v:IsA("Accessory") or
v.Parent.Name == "TWAU" or
v.Parent.Name == "EchoesA3" or
v.Parent.Name == "DiverDown" or
v.Name == "Part") then
table.insert(IgnoreList,v)
end
end
local v = workspace:FindPartOnRayWithIgnoreList(R, IgnoreList)
if v ~= nil then
if v.Parent:FindFirstChild("Humanoid") and v.Parent ~= LocalPlayer.Character and v.Parent:FindFirstChild("Deb") == nil then
local Deb = Instance.new("BoolValue", v.Parent)
Deb.Name = "Deb"
game.Debris:AddItem(Deb,0.5)
LocalPlayer.Character:FindFirstChild("Remotes").Combat:FireServer(v, Damage, Long)
end
end
end
SERVER:
script.Parent.OnServerEvent:Connect(function(player, target, damage, long)
local magnitude = (player.Character.HumanoidRootPart.Position - target.Parent.HumanoidRootPart.Position).Magnitude
if magnitude > 15 then
game.ReplicatedStorage.Client:FireClient(player)
end
target.Parent:FindFirstChild("Humanoid"):TakeDamage(damage)
local BV = Instance.new("BodyVelocity", target)
BV.maxForce = Vector3.new(25000,25000,25000)
BV.Velocity = player.Character.HumanoidRootPart.CFrame.lookVector * long
game.Debris:AddItem(BV,0.1)
local S = Instance.new("Sound", target)
S.SoundId = "rbxassetid://131237241"
S.Volume = 0.75
S.PlaybackSpeed = math.random(90,110)/100
S:Play()
end)
Yes, I could use that, but how do I detect that they are clicking? Because I dont want the exploiter to just face someone while spamming remote event (i already added a check in between remote event durations so that they cant spam it)
have a count interval and make it so if it is a fraction of like 50 for example it wont work, and on the server make sure to check their fraction count divisor to make sure it didnt change. If it did, kick them.
No like I already did that but like Im saying that I was going to use dot product but I dont want the exploiter to just face the enemy and fire the remote to deal damage, i want the exploiter to actually click to attack
no I don’t think you’re understanding my question. If I add dot product check, the exploiter can still fire remote without clicking while facing the target. I want the exploiter to click to deal damage
Yeah basically, like how to detect mouse button is clicked and if there is no detection from the mouse when the remote is fired, it can either return or kick the client
No. Local Script. Once the Left button is clicked, call your functions within the MouseButton1Click function and fire the remote event. I’m not sure if this is the safest way to do it. You might have to add a cool down in the server script to check and make sure that people can’t spam click the function.
I said the debounce should be on the server side instead of the client side. In your scripts, the client one was the one that’s adding the debounce to the target humanoid, then firing the remote, while on the server side you have no checking if the target was already hit/have a debounce or not, that means once the player gets in range of a target, and if they are an exploiter they can just mass fire the remote and bypass the cooldown