what does the remote event? aaaa
ignore the remote event, that’s my damage remote
It is used for client sided detection, but dont let that be of your concern yet.
Make sure the detection works fine first.
the only thing you need to focus on is this
if not table.find(HumTable, Humanoid) then
table.insert(HumTable, Humanoid)
--damage code
end
Client side damage detection without any server checks is something you DEFINITELY want to stay away from, or else your game will be plagued with exploiters.
for me i’ve already done an anti cheat aka server check with the damage/hitbox spamming.
ok i got this to work but it still hits like a million times
I like to make my gun systems and weapons mostly server sided. All i do is fire a remote event to the server when they click (firing the gun) and handling the viewmodel. All the checks are server side. (Though I do have the same checks on the client too!)
Add a debounce table and check if the player is already in it, if not damage them, then insert them to the table and remove them maybe a second later, or however long you want!
local Params = OverlapParams.new()
Params.FilterType = Enum.RaycastFilterType.Blacklist
Params.FilterDescendantsInstances = {plr.Character}
Params.MaxParts = 50
you should be doing a repeat until so you dont have a memory leak with while loop.
this is how the script looks like now
local Debris = game:GetService("Debris")
local humRP = player.Character.HumanoidRootPart
local TweenS = game:GetService("TweenService")
local damage = 12 * player.FLvl.Value
local parts = workspace:GetPartBoundsInRadius(humRP.Position ,40)
for i,v in pairs(parts) do
if v.Parent ~= player.Character and v.Parent:FindFirstChild("Humanoid") and v == v.Parent.HumanoidRootPart then
v.Parent.Humanoid.Health -= damage
local damageI = game:GetService("ReplicatedStorage").DmgIndicator:Clone()
damageI.Parent = v.Parent.HumanoidRootPart
damageI.TextLabel.Text = "-"..damage
damageI.StudsOffset = Vector3.new(math.random(-2,2),math.random(-2,2),math.random(-2,2))
local TweenDmg = TweenS:Create(damageI,TweenInfo.new(1,Enum.EasingStyle.Bounce,Enum.EasingDirection.Out, 0, false), {Size = UDim2.new(2,0,2,0)})
TweenDmg:Play()
TweenDmg.Completed:Connect(function()
local TweenDmg2 = TweenS:Create(damageI,TweenInfo.new(1,Enum.EasingStyle.Bounce,Enum.EasingDirection.Out, 0, false),{Size = UDim2.new(0,0,0,0)})
TweenDmg2:Play()
end)
end
end
I would connect to RunService.Heartbeat
and then increment a delta
variable once until it reaches something like 6, and then reset the delta
and run the checks. Here, using 6 will run it 10 times a second at 60 FPS.
well i got it to work only once to the other players so now it work properly
hm alright, thanks for the advice.