Does the Raycast Hitbox 4.01 support detection for when a part is touched rather than hit?
Hey! I tried both of youâre solutions @ShadowOfVenus and @Khrrxs but didnât work, so maybe someone else (or @TeamSwordphin may help me), but Iâve been experiencing some heavy inaccuracy, check the video out please (you can hear the hit sound, different on each weapon, on the few times that hitbox worked): Hitbox inaccuracy
Thank you for reading!
@TeamSwordphin Since I havenât seen any replies regarding on-touch detection, what part of the module takes care of that?
@Quellet , @MILLENNlA you could easily make one like this
fire this
newHitbox:HitStart
without doing this
newHitbox:HitStop()
then it will work like a on-touch detection
âeven in the docs it shows itâ
its in 3rd step
I see, but when doing so, it either doesnât damage or does not re-enable itself. It says that HitStop() is required to damage the character again if the player was already hit.
Can you just make a little example code of few lines with a damage function to show how it should be layed out as? Cause Iâm really confused by this.
For an example: on that sword tool featured in the file, how would I also add touch detection alongside it damaging on activate?
UPDATE: I realized that hitboxes work perfectly on dummies, the problem is on players. Can someone assume a solution from this?
UPDATE 2: I FOUND THE PROBLEM IT IS THE ACCESSORIES AND HAIR (meshes I guess) IN THE VICTIMâS CHARACTER, DO ANYONE OF YOU KNOW IF THIS HAS ANYTHING TO DO WITH ANY PART OF THE MODULE?
Edit: Iâm talking about this issue on this topic.
Thank you for reading!
Roblox is currently down
when its not I will try to do your request, âcanât access roblox studioâ
Is there a way to make it not hit players? Iâm making a script with blood droplets that make a blood puddle when they hit the ground and they keep hitting my players character and then making puddles on my character. Iâm not very experienced in raycasting yet
You need to set up a Raycast filter to ignore the character.
Example
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {char}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local Hitbox = RaycastHitbox.new(Hitbox)
Hitbox.RaycastParams = raycastParams
I know this may sound dumb, but I canât hit while moving anymore. Before I used to be able too, now I canât. I believe that it is an animation bug since it animates the tool, Iâm not sure tho. Can anyone help me with this?
Nevermind, I fixed it. It was cause my self hit detection
Do you have any example to handle player ping issue that effecting the raycast?
What do you mean? Are you handling the Raycast on the server?
Nevermind, Itâs fixed already, Thanks to HaxxerVaxxerâs post. I thought it was due to the player high ping.
I just doing some testing and for some odd reason, in studio, when I specifically âRunâ the game, the raycast works and itâs visualizing. However, when I actually âPlayâ the game in studio there is no raycast and nothing visualized. Is anyone else having this problem or know how to fix this?
THANK YOU! i seriously canât thank you enough, now i donât have to deal with all of Touchedâs problems
Iâve made local script version, using 5 parts inside of the weapon which have to be welded to reference as points so its easily adjustable for all you have to do is have a part inside of a Tool thatâs called Handle, and 5 parts called âRay1â, Ray2"⌠âRay5â. You get the point. After that you should have something like in the video. You also have to create a serverscript that will respond onserverevent of a remoteevent to actually damage the player. To add, removevent doesnt fire when ray hasnât hit player, so the server can only really overload if 1000 players hit a player at the same time With this module you will lag on 100 or less players just hitting air, promise ,since the server is generating all of the rays even they are not hitting anything important.
local runService = game:GetService("RunService")
local Detecting = false
local tool = script.Parent
local Part = {tool:WaitForChild("Ray1"),tool:WaitForChild("Ray2"),tool:WaitForChild("Ray3"),tool:WaitForChild("Ray4"),tool:WaitForChild("Ray5")}
local WS = game:GetService("Workspace")
local Debris = game:GetService("Debris")
local player = game:GetService("Players").LocalPlayer
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {player.Character,tool}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local replicatedStorage = game:GetService("ReplicatedStorage")
local RayHitDetectionEvent = replicatedStorage.RayHitDetection.Hit --create a remote event in a folder called RayHitDetection in replicatedstorage
local RayPart = replicatedStorage.RayHitDetection.Ray --make ray part choose colour and texture rest dont really matter
local RayCooldown = 1--type in seconds
local positionTable = {}
local SecondPositionTable = {}
local u = 0
local rayDelta = os.time()
local SwingDelta = os.time()
local SwingDelay = 3 --seconds
local function VisualiseNonHitRay(rayOrigin,rayDirection,rayDestination, i)
local part = RayPart:Clone()
part.Parent = Part[i]
part.CFrame = CFrame.lookAt(rayOrigin,rayDestination)
part.Size = Vector3.new(0,.1,(rayOrigin-rayDestination).Magnitude)
Debris:AddItem(part, .5)
end
local function CreateRay(rayOrigin,rayDirection,rayDestination, i)
local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
if raycastResult then
local hitPart = raycastResult.Instance
if hitPart.Parent then
if hitPart.Parent:FindFirstChild("Humanoid") then
--print("Attacked Humanoid")
if hitPart.Parent == player.Character then
else
if hitPart.Parent.Humanoid.Health>0 then
RayHitDetectionEvent:FireServer(hitPart.Parent)
end
end
end
end
else
VisualiseNonHitRay(rayOrigin,rayDirection,rayDestination, i)
end
end
function RayHitbox()
rayDelta=os.time()
while Detecting==true do
for i,v in pairs (Part) do
positionTable[i] = v.Position
end
u=u+1
runService.RenderStepped:Wait()
for i,v in pairs (Part) do
SecondPositionTable[i] = v.Position
end
for i,v in pairs(positionTable) do
if (v-SecondPositionTable[i]).Magnitude > math.pi then
else
CreateRay(v,SecondPositionTable[i]-v,SecondPositionTable[i], i)
end
end
if u == RayCooldown*60 then
u=0
Detecting=false
coroutine.yield()
end
if os.time()-RayCooldown>rayDelta then
rayDelta=os.time()
Detecting=false
coroutine.yield()
end
end
coroutine.yield()
end
local function Start()
if os.time()-SwingDelay > SwingDelta then
SwingDelta = os.time()
Detecting = true
local Rays = coroutine.create(RayHitbox)
coroutine.resume(Rays)
end
end
tool.Equipped:Connect(function()
tool.Activated:Connect(Start)
end)
âEdits, just improved a bit of code so you couldnât press down and keep damaging people
Just use :GetTouchingParts() its more convenient
Turn off CanQuery in accessories so the raycasts from the module will ignore them
I did that a couple months ago (right after posting it here) and it worked, thank you anyways!