Issue with Region3 Hitbox

My problem is that i whenever i fireserver this code everything is sometimes fine,but sometime it dosen’t the problem is the region3 sometime dosen’t hit the target but the Part hitbox works fine. Pls help me solved this problem, and also i might replie late, so sorry in advance so pls send me some example or an clear explanation will great. Thank you :sunglasses: :sunglasses: :sunglasses:
Here’s the code
game.ReplicatedStorage.Folder.Punxh1.OnServerEvent:Connect(function(Player)
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild(“Humanoid”)
local HumRoot = Character.HumanoidRootPart
local CS = game:GetService(“CollectionService”)
local Fstun = Character:FindFirstChild(“Stun”)
local Frag = Character.Effects:FindFirstChild(“Ragdoll”)
local Effect = script.Parent.Eff14:WaitForChild(“Attachment”):Clone()
local Effect2 = script.Parent.blockEf:WaitForChild(“Attachment”):Clone()
local I = Instance.new(“Animation”)
I.AnimationId = “rbxassetid://9302669155”
local Effec2t = script.Parent.blockEf:WaitForChild(“Attachment”):Clone()
local Hitbox = Instance.new(“Part”)
Hitbox.Size = Vector3.new(3.174, 2.11, 2.634)
Hitbox.CFrame = HumRoot.CFrame + HumRoot.CFrame.LookVector * 1.678
Hitbox.CanCollide = false
Hitbox.CanTouch = true
Hitbox.Anchored = false
Hitbox.Archivable = true
Hitbox.Locked = false
Hitbox.CastShadow = false
Hitbox.Transparency = 1
Hitbox.Massless = true
local Weld = Instance.new(“WeldConstraint”)
local Fblock = Character:FindFirstChild(“IsBlocking”)
local Weld2 = Instance.new(“Weld”)
local TS = game:GetService(“TweenService”)
local Plr = Player.Combo
local Jha = game.StarterPlayer.StarterCharacterScripts.Humanoid.Humanoid.WalkSpeed
local Jha2 = game.StarterPlayer.StarterCharacterScripts.Humanoid.Humanoid.JumpPower
---------------------------------------------------------------------------------------------------
local HitEffect = script.Parent:WaitForChild(“HitEffect”).Hiteffect:Clone()

local Plcobo = Player.Combo.Value

if Frag == nil and not Character:FindFirstChild("Stun") and not Character:FindFirstChild("BlockHits") then

	local Region = Region3.new(Hitbox.Position - Hitbox.Size/2,Hitbox.Position + Hitbox.Size/2)
	local partsInRegion = workspace:FindPartsInRegion3(Region,Hitbox)
	Hitbox.Parent = game.Workspace.BoxFolder
	Weld.Part0 = Hitbox
	Weld.Part1 = HumRoot
	Weld.Parent = HumRoot
	game.Debris:AddItem(Weld,0.2)
	game.Debris:AddItem(Hitbox,0.2)

	local debounce = false

	for i,v in pairs(partsInRegion) do

		local hit = v.Parent
		local Hum = hit:FindFirstChild("Humanoid")
		local FF1 = v.Parent:FindFirstChild("BlockHits")
		-----------------------------------------------------------------------------------------
	

		if Hum and not debounce and hit ~= Character then
			debounce = true
			Hum:TakeDamage(100)
			print("Hitted")
		end
			
			




	end




end

end)

maybe you could try Roblox’s new spatial query

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

1 Like