#Damage application only works randomly

1 messages · Page 1 of 1 (latest)

golden wolf
#

https://streamable.com/ebuxys

local WS = game:GetService("Workspace")
local RUN= game:GetService("RunService")
local RUNconn

local Sword = script.Parent
local Character = Sword.Parent
local Hitbox    = Sword.Hitbox

local RemDmg    = Sword.RemoteDamage

local Params    = OverlapParams.new()
Params.FilterType = Enum.RaycastFilterType.Exclude
Params.FilterDescendantsInstances = {Character}
Params.CollisionGroup = "Damager"
Params.RespectCanCollide = false

local HitList = {}

RemDmg.OnServerEvent:Connect(function(_,bool)
  if  bool == "true" then
      table.clear(HitList)
      if  RUNconn then RUNconn:Disconnect() RUNconn = nil end

      RUNconn = RUN.Heartbeat:Connect(function()
        local    Parts = WS:GetPartsInPart(Hitbox,Params)
        if       #Parts == 0 then return end
        for      _, p in Parts do
          local  Hum   = p.Parent:FindFirstChildOfClass("Humanoid")
                 print(p)
          if     Hum and not HitList[Hum] then
                 HitList[Hum] = true
                 Hum:TakeDamage(20)
          end
        end
      end)
  elseif bool == "false" and RUNconn then
         RUNconn:Disconnect()
         RUNconn = nil
         table.clear(HitList)
  end
end)

Thats the ServerScript in the Sword-Tool which lays in StarterPack

Watch "Issue with damage application" on Streamable.

▶ Play video
stiff spire
#

what am i even looking at

#

i love how exploiters can deal infinite damage with this sword

golden wolf
#

LocalScript

local    PLAYERS       =    game:GetService("Players")

local    Player        =    PLAYERS.LocalPlayer
local    Character     =    Player.Character or Player.CharacterAdded:Wait()

local    Sword         =    Character:WaitForChild("Sword")

local    RemDmg        =    Sword:WaitForChild("RemoteDamage")

local    Humanoid      =    Character:WaitForChild("Humanoid")
local    Animator      =    Humanoid:WaitForChild("Animator")
local    Animation1    =    Instance.new("Animation")
         Animation1.AnimationId    =  "rbxassetid://767517273XXXXX"

local    Anim1Track    =    Animator:LoadAnimation(Animation1)

         Anim1Track:GetMarkerReachedSignal("Damage"):Connect(function(bool)
              RemDmg:FireServer(bool)
         end)

while task.wait(5) do
Anim1Track:Play()
end
golden wolf
#

im relatively new to scripting and this is my first simple attempt

stiff spire
#

its not random

#

its just inaccurate

#

do everything entirely on the server

#

including animation

#

because thats why its inaccurate; you fire a remote on the animation marker; this does not reach the server in 0ms, it takes time. by the time the server finds out that you pressed swing, the animation is likely already over

#

so just do it all on the server

#

that's how tsb does it

golden wolf
golden wolf
# stiff spire that's how tsb does it

i never played tsb but do games who have like 10-20 players fighting at the same time also handle it entirely on the server? eg deepwoken, blackout revival etc

brave ridgeBOT
#

studio** You are now Level 4! **studio

stiff spire
#

if they don't, it's all serverside

golden wolf
#

are there large fights in tsb as well? with 10+ ppl

stiff spire
#

i think their server cap is 10+ so yea

#

i think you're getting the wrong impression from this

#

just do it on the server

#

dont waste your time making a custom rollback netcode

#

yes i'm aware it has input delays, just deal with it

#

roblox will be releasing a built-in system that lets you do rollback netcode natively, without much of any extra work. not much point putting in effort that's going to be replaced by that system in a few months

golden wolf
#

alright, solving my issue and informing me about these things helped a lot