Need Help for combat

1. What do you want to achieve? Keep it simple and clear!
I want help with a combat system

2. What is the issue? Include screenshots / videos if possible!
mine is just trash

3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i tried reworking it but it didn’t work

this is the server

local ragdoll = require(script.RagdollModule)
local combatModule = require(script.ModuleScript)
game.ReplicatedStorage.Events.Combat.OnServerEvent:Connect(function(plr,click,uis2)
	print(plr)



	local hitbox = Instance.new("Part",workspace)
	hitbox.CanCollide = false 
	hitbox.Anchored = true
	hitbox.Size = Vector3.new(5,5,5)
	hitbox.Transparency = 0.3
	hitbox.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-2)
	game.Debris:AddItem(hitbox,2)






	local Hits = {}
	hitbox.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") then
		if  hit.Parent.Name == plr.Character.Name then return end
		if hit.Parent.Name ~= plr.Character.Name then
			if Hits[hit.Parent.Name] then
				return
			end



			Hits[hit.Parent.Name] = true
			local mathrandom = math.random(3,6)
				hit.Parent:FindFirstChild("Humanoid"):TakeDamage(mathrandom)
				print(combatModule.Sword.Damage)

				
				
				local bh = game.ReplicatedStorage.basicHit.Main:Clone()
				bh.Hitter.HitCounter.Text = mathrandom
				bh.Parent = hit.Parent.HumanoidRootPart
			
			bh.Parent = hit.Parent.HumanoidRootPart
			for i,v in pairs(bh:GetChildren()) do
				if v:IsA("ParticleEmitter") then
					v:Emit(v:GetAttribute("EmitCount"))
				end
			end
			game.Debris:AddItem(bh,0.5)
				if click == 3 then
	ragdoll.Ragdoll(a,hit.Parent)
					local knockback = Instance.new("BodyVelocity",hit.Parent.HumanoidRootPart)
				knockback.P = math.huge
					knockback.Velocity = hitbox.CFrame.LookVector * 15
			
				knockback.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
				local track = hit.Parent.Humanoid:LoadAnimation(script.knockback)
				track:Play()

				game.Debris:AddItem(knockback,1)
					mathrandom = 10
					wait(3)
					ragdoll.Unragdoll(a,hit.Parent)
			end

				



			for i,v in pairs(bh:GetChildren()) do
				if v:IsA("BillboardGui") then
					v:Clone()
					v.Parent = hit.Parent.HumanoidRootPart
					v.HitCounter.Text = mathrandom
					print(mathrandom)
					game.Debris:AddItem(v,0.5)
				end
				end
				
				hit.Parent.Humanoid.WalkSpeed = 0
				wait(1)
			hit.Parent.Humanoid.WalkSpeed = 16
			wait(4)
			Hits[hit.Parent.Name] = false

		end
end
	end)
end)


this is client

local event = game.ReplicatedStorage.Events.Combat
local Player = game.Players.LocalPlayer
local uis = game:GetService("ContextActionService")
local uis2 = game:GetService("UserInputService")

local click = 1
local CombatAnim= {
	"rbxassetid://18252851569",
	"rbxassetid://18252843860",
	"rbxassetid://18252851569",
	"rbxassetid://18252843860"
}

local DashAnim= {
	"rbxassetid://18252862582",
	"rbxassetid://18252862582"


}


local db2 = false
local db = false
function click_Touch ()

	if db == true then return end
	db =true	
	event:FireServer(click,uis2)
	click = click +1

	script.Punch.AnimationId = CombatAnim[click]
	local anim = Player.Character.Humanoid:LoadAnimation(script.Punch)
	anim:Play()


	Player.Character.Humanoid.JumpPower = 0

	if click == 4 then
		click = 0
	end



	print(click)

	print("pressed")
	wait(0.6)
	db =false
end





function Dash ()
	local Front = DashAnim[1]
	local Left = DashAnim[2]
	if db2 == true then return end
	db2 = true
	local dash_velocity = Instance.new("BodyVelocity",Player.Character.HumanoidRootPart) 
	dash_velocity.MaxForce = Vector3.new(math.huge,0,math.huge)

	if uis2:IsKeyDown(Enum.KeyCode.W) or Player.Character.Humanoid.MoveDirection.Magnitude == 0 then
		script.Animation.AnimationId = Front
		dash_velocity.Velocity = Player.Character.HumanoidRootPart.CFrame.LookVector *50
	elseif uis2:IsKeyDown(Enum.KeyCode.A) then
		script.Animation.AnimationId = Left
		dash_velocity.Velocity = Player.Character.HumanoidRootPart.CFrame.RightVector *-50
	elseif uis2:IsKeyDown(Enum.KeyCode.D) then
		script.Animation.AnimationId = Left
		dash_velocity.Velocity = Player.Character.HumanoidRootPart.CFrame.RightVector *50
	elseif uis2:IsKeyDown(Enum.KeyCode.S) then
		dash_velocity.Velocity = Player.Character.HumanoidRootPart.CFrame.LookVector *-50

	end
	local anim = Player.Character.Humanoid:LoadAnimation(script.Animation)
	anim:Play()

	wait(0.3)
	dash_velocity:Destroy()

	wait(2)
	db2 = false
end

uis:BindAction("Dash",Dash,true,Enum.KeyCode.Q)

uis:BindAction("ClickTouch",click_Touch,true,Enum.UserInputType.MouseButton1)
1 Like

This is not the appropriate place to request others to write code for you. Please provide the code you have attempted so far to show that you’ve put in some effort and for us to see what we are working with.

1 Like

ok, i want trying ask anyone` to write a full combat script i was asking about any ideas i can use to help.

1 Like

Roblox has template games that you can mess around with. These may help you get an idea of what kind of system you want.

1 Like

that did not help i dont want to copy

1 Like

you should explain why you think its trash or what parts are not good

1 Like

Hi! What parts do you not like about it, and what parts do like? Also did you write this code?

1 Like

Biggest problem I can see immediately is that you’re using .Touched() for your hitboxes. I’ve got a guide on hitboxes here.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.