You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
The type of hitbox im using is GetPartsInParts, if this information is important.
What im trying to do is make it so that even if the Hitbox hits the mob, but, the mob is behind a wall Itll ignore it. But if its hitting mobs thats not in behind of a wall then itll still hit the mobs. The other problems Ive encountered is that when making that script, when the mobs stack up on each other (the mobs dont have collision they can go inside each other) the Raycast think that its a wall and just ignores it.
The part that is red well call Hitbox. What im scared is the Raycast will detect theres a wall and then just ignores the other mobs that are not behind the wall.
This script is a module script, I thought itd be an important information.
local DamageValue = 50
local Damageable = true
local DamageIgnore = true
local KnockbackValue = 0
local StunValue = 0
local SoundID = 5801257793
local HBSize = Vector3.new(90,5,50)
local HBDistance = HBSize.Z/2
local Character = Player.Character
local CharacterTorso = Character:FindFirstChild("Torso")
local CharacterHum = Character:WaitForChild("Humanoid")
local CharacterRootPart = Character:FindFirstChild("HumanoidRootPart")
local Position = Character
and Character:FindFirstChild("Torso")
and Character.Torso.Position
if not Position then
return
end
local HB = Instance.new("Part")
HB.Parent = Character
HB.Size = HBSize
HB.PivotOffset = CFrame.new(1,0,0)
HB.Transparency = 0.9
HB.CanCollide = false
HB.Massless = true
HB.Anchored = false
local Weld = Instance.new("Weld")
Weld.Parent = HB
Weld.Part0 = CharacterRootPart
Weld.Part1 = HB
Weld.C1 = CFrame.new(0,0,HBDistance)
local Sound = Instance.new("Sound")
Sound.SoundId = "rbxassetid://"..SoundID
Sound.Parent = CharacterTorso
local AttachmentCloned
for i, Attachment in pairs(EffectsFolder.Explosion:GetDescendants()) do
if Attachment:IsA("Attachment") then
AttachmentCloned = Attachment:Clone()
AttachmentCloned.Parent = Character:FindFirstChild("Right Arm")
end
end
local Animations = {
Test = CharacterHum:WaitForChild("Animator"):LoadAnimation(AnimationsFolder.TestAnim)
}
Animations.Test:Play()
Animations.Test:GetMarkerReachedSignal("Attack"):Connect(function()
for i, EffectsToPlay in pairs(AttachmentCloned:GetDescendants()) do
if EffectsToPlay:IsA("ParticleEmitter") then
EffectsToPlay:Emit(EffectsToPlay:GetAttribute("Emit"))
Sound:Play()
task.delay(Animations.Test.Length,function()
AttachmentCloned:Destroy()
end)
end
end
local PartsInParts = workspace:GetPartsInPart(HB)
local function RegisterHit(v)
local FindMob = v.Parent
if FindMob:HasTag("Mob") then
local FindMobTorso = FindMob:FindFirstChild("Torso")
if not FindMobTorso then
return
end
task.spawn(function()
RequestStunMob(FindMob, StunValue)
Knockback:Activate(FindMobTorso, KnockbackValue, Position, FindMobTorso.Position)
if Damageable then
Damage:DamageMob(Player, MobList[FindMob], {Ignore = DamageIgnore, Damage = DamageValue})
end
pcall(function()
FindMobTorso:SetNetworkOwner(Player)
end)
end)
end
end
for i, v in pairs(PartsInParts) do
RegisterHit(v)
end
task.delay(Animations.Test.Length, function()
HB:Destroy()
end)
end)