How to make these hitbox work

Hi so i made a StarterCharacter and i made this:


3 red box is 3 hitbox

  • TopHitbox
  • MidHitbox
  • LowHitbox

they are all weld to the HumanoidRootPart

I use RemoteEvent to make cilent β†’ server
image

LocalScript (inside StarterCharacterScript):

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TopRemoteEvent = ReplicatedStorage:WaitForChild("TopDamageTrigger")
local MidRemoteEvent = ReplicatedStorage:WaitForChild("MidDamageTrigger")
local LowRemoteEvent = ReplicatedStorage:WaitForChild("LowDamageTrigger")

UIS.InputBegan:Connect(function(Input, gpe)
	if not gpe then
		if Input.UserInputType == Enum.UserInputType.MouseButton1 and Attackable == true and Combo == 1 then
			Slash1:Play()
			Attackable = false
			MidRemoteEvent:FireServer(Player,"True")--1st slash
			wait(0.18)
			Attackable = true--debounce
			Combo = Combo + 1--make next move	
			print(Combo)--test
		elseif Input.UserInputType == Enum.UserInputType.MouseButton1 and Attackable == true and Combo == 2 then
			Slash2:Play()
			Attackable = false
			MidRemoteEvent:FireServer(Player,"True")--2nd slash
			wait(0.18)
			Attackable = true
			Combo = Combo + 1	
	 		print(Combo)
		elseif Input.UserInputType == Enum.UserInputType.MouseButton1 and Attackable == true and Combo == 3 then
			Slash3:Play()
			Attackable = false
			TopRemoteEvent:FireServer(Player,"True")--3rd slash
			wait(0.33)
			Attackable = true
			Combo = Combo + 1	
			print(Combo)
		elseif Input.UserInputType == Enum.UserInputType.MouseButton1 and Attackable == true and Combo == 4 then
			Slash4:Play()
			Attackable = false
			MidRemoteEvent:FireServer(Player,"True")--4th slash
			wait(0.33)
			Attackable = true
			Combo = Combo + 1	
			print(Combo)
		elseif Input.UserInputType == Enum.UserInputType.MouseButton1 and Attackable == true and Combo == 5 then
			Slash5:Play()
			Attackable = false
			LowRemoteEvent:FireServer(Player,"True")--double
			wait(0.2)
			LowRemoteEvent:FireServer(Player,"True")--slash
			wait(0.3)
			Attackable = true
			Combo = Combo - 4--reset combo
			print(Combo)
		end
	end
end)

Server script (in ServerScriptService):

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TopRemoteEvent = ReplicatedStorage:WaitForChild("TopDamageTrigger")
local MidRemoteEvent = ReplicatedStorage:WaitForChild("MidDamageTrigger")
local LowRemoteEvent = ReplicatedStorage:WaitForChild("LowDamageTrigger")

TopRemoteEvent.OnServerEvent:Connect(function(x)
	print(x)--test
	--make TopHitbox Damage
end)
MidRemoteEvent.OnServerEvent:Connect(function(y)
	print(y)
	--Make MidHitbox Damage
end)
LowRemoteEvent.OnServerEvent:Connect(function(z)
	print(z)
	--Make LowHitbox Damage
end)

can someone help me PLEASE because i cant define the player character in server script (to define the hitbox)

- - Also, i just learn how to use RemoteEvent on YT :slight_smile: - -

1 Like

I would recommend using Raycast Hitboxes! Although for this, your best bet would be to use the WorldRoot:GetObjectsInPart() function I think it’s called that at least.

I am really (really) suck at scripting
i dont understand :sad:
srry

Try :GetTouchingParts for a base part is the best place to start! Place the HItbox at the characters positions, then use :GetTouchingParts() then run it through the table it returns, and get characters within the hitbox!

1 Like

https://developer.roblox.com/en-us/api-reference/function/WorldRoot/GetPartsInPart

I believe this is the function you’re referring to.

https://developer.roblox.com/en-us/api-reference/function/WorldRoot/ArePartsTouchingOthers

You can also use this to first check if a part is touching any other part.

1 Like