RaycastHitboxV4 .OnTouch not working

  1. What do you want to achieve? I got a Hitbox, and i want it to detect touch.

  2. What is the issue? It used to work fine, but it stopped working for some reason

  3. What solutions have you tried so far? i’ve tried debugging to see what the hell is going on to no avail

Not sure if this is the right place to get help with this module script. The original topic is dead so i can’t ask for help there.

-- This Local script creates the Hitboxes
local RaycastHitbox = require(game:GetService("ReplicatedStorage").Modules.RaycastHitboxV4)

local Table = {"RightHand","LeftHand","RightFoot","LeftFoot"}
local Character = script.Parent

local Parameters = RaycastParams.new()
Parameters.FilterDescendantsInstances = {Character}
Parameters.FilterType = Enum.RaycastFilterType.Exclude
-- Makes a Hitbox for each Bodypart in Table
for i, PartName in ipairs(Table) do
	local BodyPart = Character:WaitForChild(PartName)
	if BodyPart then
		local NewHitbox = RaycastHitbox.new(BodyPart)
		NewHitbox.RaycastParams = Parameters
	end
end

This one is supposed to Detect touch, and it worked until something i did in some script somewhere made it stop working.

local RayHitBox = require(game.ReplicatedStorage.Modules.RaycastHitboxV4)
local RemoteEvent = game:GetService("ReplicatedStorage").Remotes.RayHitboxClient

RemoteEvent.OnClientEvent:Connect(function(Part, Attack)
	-- Gets Hitboxes made in last script
	local Hitbox = RayHitBox.new(Part)
	print(Hitbox, Part, Part.Parent) -- Prints out the Hitbox, BodyPart and Character as it should
	
	Hitbox.OnHit:Connect(function(Hit, Human)
		print("This message is never printed out...")
	end)
	Hitbox:HitStart(1)	
end)

1 Like

I think what’s causing the issue is that you are using it in a LocalScript. Don’t do that

2 Likes

Try starting the hitbox for longer periods of time.

You only start the hitbox for 1 second, so I don’t know if it is actually hitting anything in that 1 second.

2 Likes

both of the scripts are local, i need to do it in local scripts, else the hitboxes will lag behind the player. Also this script used to work before, and it was on local back then.

2 Likes

Nope, that’s not the problem, i’ve done hitboxes for 0.45 seconds and they still work.

1 Like

Wait, I think I know the problem.

Do you have any attachments in the body parts named “DmgPoint”?

You need to have attachments in the body parts with the name “DmgPoint” for there to even be any type of hitbox to toggle on or off.

If you need to make a hitbox through RaycastHitboxV4, they have a function for it called :SetPoints(). You probably need to use this to make the hitbox for the body parts.

2 Likes

Yes, all four of bodyparts have DmgPoints. I make them in another script as soon as the character spawns

1 Like

Try turning on the vizualizers and seeing if they actually turn on.

1 Like

They are on, the hitboxes don’t really start because i can’t see them. They used to start like normal and i’d be able to see them tho.

Update: this script breaks the hitboxes, idk why.

-- This Local script creates the Hitboxes
local RaycastHitbox = require(game:GetService("ReplicatedStorage").Modules.RaycastHitboxV4)

local Table = {"RightHand","LeftHand","RightFoot","LeftFoot"}
local Character = script.Parent

local Parameters = RaycastParams.new()
Parameters.FilterDescendantsInstances = {Character}
Parameters.FilterType = Enum.RaycastFilterType.Exclude
-- Makes a Hitbox for each Bodypart in Table
for i, PartName in ipairs(Table) do
	local BodyPart = Character:WaitForChild(PartName)
	if BodyPart then
		local NewHitbox = RaycastHitbox.new(BodyPart)
		NewHitbox.RaycastParams = Parameters
	end
end

I fixed this by making it run in the second script when the Hitbox hasn’t been created yet

local ConfigHitbox = function(Part, Character)
	
	local Hitbox = RayHitBox:GetHitbox(Part)
	
	if Hitbox then
		return Hitbox
	else
		Hitbox = RayHitBox.new(Part)
		Hitbox.Visualizer = true
		local Parameters = RaycastParams.new()
		Parameters.FilterDescendantsInstances = {Character}
		Parameters.FilterType = Enum.RaycastFilterType.Exclude
		Hitbox.RaycastParams = Parameters
		
		return Hitbox
		
	end
	
end

RemoteEvent.OnClientEvent:Connect(function(Part,Attack)
	
	local Hitbox = ConfigHitbox(Part, Character)

end)

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