#hitboxes

1 messages · Page 1 of 1 (latest)

cerulean gazelle
#

i cant get hitboxes to do anything no matter what hitbox i try maybe this is some dumb mistake im making but the hitbox is the only problem

brave hazel
#

code?

sharp bay
#

Character hitbox is the humanoid

#

should send the code for better understanding

cerulean gazelle
#

local Hitbox = {}
Hitbox.__index = Hitbox

function Hitbox.new(Player, Size, cframe)
local self = {}
setmetatable(self, Hitbox)

self.Owner = Player

self.HB_Part = Instance.new("Part")
local HB = self.HB_Part
HB.Parent = workspace.Fx
HB.Size = Size
HB.CFrame = cframe
HB.Anchored = true
HB.CanCollide = false

HB.Touched:Connect(function()
end)

return self

end

function Hitbox:DamageTargets(damage)
local HB: BasePart = self.HB_Part

local targets = {}

for i,v in pairs(HB:GetTouchingParts()) do
    local hum = v.Parent:FindFirstChild("Humanoid")
    
    if hum and hum.Parent ~= self.Owner.Character then
        if not table.find(targets, v.Parent) then
            table.insert(targets, v.Parent)
        end
    end
end

for i,v in pairs(targets) do
    local targetHum = v.Humanoid
    if targetHum then
        targetHum.Health -= damage
    end
end

return targets

end

function Hitbox:Destroy()
self.HB_Part:Destroy()
end

return Hitbox

cerulean gazelle
sharp bay
#

good practice

#

ill take a read later, I don’t have much time to absorb what is wrong.

You can try putting the code in roblox assistant and it will point out the error

cerulean gazelle
sharp bay
#

or function B is called inside function A

#

Havent read it but try to see if that’s the problem

#

If not then take a read if what u assigned to the variables is valid

lean ivy
#

sorry to interrupt, please make it like this

#
local Hitbox = {}
Hitbox.__index = Hitbox

function Hitbox.new(Player, Size, cframe)
    local self = {}
    setmetatable(self, Hitbox)
    
    self.Owner = Player
    
    self.HB_Part = Instance.new("Part")
    local HB = self.HB_Part
    HB.Parent = workspace.Fx
    HB.Size = Size
    HB.CFrame = cframe
    HB.Anchored = true
    HB.CanCollide = false
    
    HB.Touched:Connect(function()
    end)
    
    return self
end

function Hitbox:DamageTargets(damage)
    local HB: BasePart = self.HB_Part
    
    local targets = {}
    
    for i,v in pairs(HB:GetTouchingParts()) do
        local hum = v.Parent:FindFirstChild("Humanoid")
        
        if hum and hum.Parent ~= self.Owner.Character then
            if not table.find(targets, v.Parent) then
                table.insert(targets, v.Parent)
            end
        end
    end
    
    for i,v in pairs(targets) do
        local targetHum = v.Humanoid
        if targetHum then
            targetHum.Health -= damage
        end
    end
    
    return targets
end

function Hitbox:Destroy()
    self.HB_Part:Destroy()
end


return Hitbox
#

whats the problem here

#

is the hitbox being silly

cerulean gazelle
#

so everything work its just not creating a hitbox

fresh creekBOT
#

studio** You are now Level 1! **studio

lean ivy
#

not creating?

cerulean gazelle
#

idk how to explain it im very new and ive been following youtube tuts for the last few hours but in the video it worked and now it dont

lean ivy
#

is it not showing up or not creating

#

does it show up in workspace

cerulean gazelle
#

i wanna use a getmarkerreachedsignal and just use hit events but im still learning

cerulean gazelle
cerulean gazelle
lean ivy
#

it doesnt exist in workspace?

cerulean gazelle
#

do i have to make a hitbox for it to find?

lean ivy
#

show your mainscript

#

where you create the hitbox

#

main function, not all of the script

#

also why are doing gettouchingparts

#

u can litterally shorten all of your module script using getpartboundsinbox

#

it's simplier

cerulean gazelle
#

ngl i think the hitbox i had isnt the one that goes with my combat system in my main script im using getmarkerreachedsignal

#

this workspace is a mess

cerulean gazelle
lean ivy
#

only this?

cerulean gazelle
#

yes the bugs in the combat it would be super swag

lean ivy
#

only hitbox thing?, aight i'll try