Help in combat system

i want it to look like this

but i got these when i tried to replicate them



they might look the same but the problem in here is that in my combat system the characters there get flinged far away on first hit then normal on the rest of the hits

second problem is that movement is not sync and laggy to control when real roblox players try to combat in here and yeah i know that could be network ownership but i dont know how to fix it

heres the localscript for the tool im using

local tool = script.Parent
local animationobject = tool.Slash
local event = game.ReplicatedStorage.RemoteEvent
local hit = game:GetService("SoundService")["Hammer Hit1"]

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

local humanoid = character:WaitForChild("Humanoid")
local animator : Animator = humanoid.Animator

local animation = animator:LoadAnimation(animationobject)
local debounce = false

local params = OverlapParams.new()
params.FilterDescendantsInstances = {character}
params.FilterType = Enum.RaycastFilterType.Exclude

tool.Activated:Connect(function()
	if debounce then
		return
	end
	debounce = true
	local direction = character.PrimaryPart.CFrame.LookVector
	local parts = workspace:GetPartBoundsInBox(CFrame.new(direction * 3 + character.PrimaryPart.Position), Vector3.new(4,4,4), params)
	for _,part in parts do
		if part.Name ~= "Handle" then
		local char = part.Parent
		local human = char:FindFirstChild("Humanoid")
		local root = char.PrimaryPart
		if char and human and root then
			event:FireServer(human, root, char)
			root:ApplyImpulse((direction + Vector3.new(0, 0.2, 0)) * 100 * root.AssemblyMass)
			break
		end
	end
	end
	animation:Play()
	hit:Play()
	task.wait(0.25)
	debounce = false
	print("fired", animator)
end)

script in serverscriptservice

local ts = game:GetService("TweenService")
local event = game.ReplicatedStorage.RemoteEvent

local info = TweenInfo.new(0.15, Enum.EasingStyle.Quint, Enum.EasingDirection.Out, 0, false, 0)

event.OnServerEvent:Connect(function(player, humanoid, root, opponent)
	print(opponent)
	local highlight = opponent:FindFirstChild("Highlight")
	if not highlight then
		highlight = Instance.new("Highlight")
		highlight.OutlineTransparency = 1
		highlight.FillTransparency = 1
		highlight.Parent = opponent
		end
		local tween = ts:Create(highlight, info, {FillTransparency=1})
		local tween2 = ts:Create(highlight, info, {FillTransparency=0.5})
		if tween.PlaybackState == Enum.PlaybackState.Playing then
			tween:Pause()
		end
		tween2:Play()
		tween2.Completed:Wait()
		if tween2.PlaybackState == Enum.PlaybackState.Playing then
			tween2:Pause()
		end
		tween:Play()
	root:SetNetworkOwner(player)
	humanoid:TakeDamage(math.random(5,15))
end)

anyone got a solution for this?

2 Likes

The second problem I think is caused by you doing root:SetNetworkOwner(player) maybe try removing that line and see if it fixes it

If you want consistent physics logic for a player, perhaps it’s best to fire the impulse on their client?

I’ve noticed in my own experience that set network owner doesn’t do much when it comes to players.

Your logic ideally might look like this: Check that the attacker’s distance to the opponent is within sword range (to prevent exploiting), then fire a remote to the opponent’s client that makes them get knocked back in the specified direction.

i already did that the impulse does nothing in client

i already did that the :ApplyImpulse() has too little effect