-
What do you want to achieve? Keep it simple and clear!
Trying to make a hitbox only detect 1 person. -
What is the issue? Include screenshots / videos if possible!
My issue is that my hitbox detection system is somewhat unique. It utilizes the ‘workspace:GetPartBoundsInBox()’ function and is designed to detect ‘CharacterHitboxes’ (a folder in workspace containing all the hitboxes of the players in game) . Inside this folder, there is a part that is welded to a player’s HumanoidRootPart when they join the game. Each Hitbox (welded part) contains an ObjectValue, which value is the character the hitbox is welded to, and when a raycast intersects with this hitbox, it’s supposed to identify the associated player and apply damage. However, I’m uncertain about how to make it work for only one player at a time. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve checked out the Roblox Dev Forum and tried a little experiment of my own. Basically, I’m keeping track of players in a list and making sure it doesn’t go beyond one player. The idea is to only deal damage to those in the list. I also played around with some other ideas, but I can’t remember all the specifics right now.
local hitboxSize = Vector3.new(3.5, 3.5, 3)
for i=1,5 do
local pos = RootPart.CFrame * CFrame.new(0,0,-2)
if Character.Humanoid.MoveDirection.Magnitude >0 then
pos = pos * CFrame.new(1,0,-1)
hitboxSize = hitboxSize + Vector3.new(1,0,-1)
end
local partsInRegion = workspace:GetPartBoundsInBox(pos,hitboxSize,params)
for _,v in pairs(partsInRegion) do
if v and v.Character.Value ~= Character then
local target = v.Character.Value
task.spawn(serverfunctions.dmg,Character,target)
end
end
task.wait(.05)
end