Is there a better way to make a Hitbox or to edit this one?

Hello everyone,I am working on a new combat system and I’ve have made the HitBox as a part is added to the workspace when the RemoteEvent is fired.I’ve noticed that the HitBox isn’t added in the perfect Position[Infront of the player].I don’t know if there is a better way to make a HitBox or to just fix this one or this is the normal Hitbox and this is not an issue.
Thanks in Advance

ServerScript:-

HitRE.OnServerEvent:Connect(function(Player , Count)
	local Chara = Player.Character
	local Hrp = Player.Character:WaitForChild("HumanoidRootPart")
	Chara.Sounds.Effects.Swish_Sound:Play()
	local Humanoid = Player.Character:FindFirstChild("Humanoid")
	
	local HitBox = Instance.new("Part",workspace)
	
	HitBox.CFrame = Player.Character:FindFirstChild("HumanoidRootPart").CFrame * CFrame.new(0,0,-5)
	HitBox.Size = Vector3.new(5,5,5)
	HitBox.Name = "HitBox"
	HitBox.Anchored = true
	HitBox.CanCollide = false
	HitBox.Transparency = 0.5
	local tq = Player.Character:FindFirstChild("Right Arm"):FindFirstChild("Trail")
	local tqq  = Player.Character:FindFirstChild("Left Arm"):FindFirstChild("Trail")
	tq.Enabled = true
	tqq.Enabled = true
	game.Debris:AddItem(HitBox , 0.5)
	wait(0.4)
	tq.Enabled = false
	tqq.Enabled = false
	
end)

Issue Video:-
robloxapp-20240731-1635109.wmv (2.7 MB)

2 Likes

Just use workspace:GetPartsBoundInBox
:smiley:

3 Likes

because while you are moving, you are moving away from the hitbox :man_facepalming:

To make it follow the player, use welds

No it acctually add new part every single time the player press M1 its not about moving away from the part

yes it is?

Try my solution and then try to convince me why it wouldent work

I think i did what you mean did you mean to add a part and weld it to the player every time the character is added? by using

Player.CharacterAdded
then Add a part and weld it to the player?

same thing as what you did first attempt, but rather than anchoring, just use welds

@wolfmanOs
here’s a suggestion

make hitbox as accessory and provide it to everyplayer who joins

when you do this you can have hitboxes on several parts of the character for example hand for punch and leg for kick

when you kick use the parts on legs to see if that hitbbox hit the enemy and the enemy receives damage

now I haven’t done this yet, it’s just an idea i am thinking for a while now and haven’t tested it yet

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