#hitboxes
1 messages · Page 1 of 1 (latest)
code?
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
ik using touched:connect is bad but im very new
Ah a custom hitbox
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
i tried that and it only gave me a summary of the script explaining what it SHOULD do perfectly but its not creating the hitbox
There are two functions. If one functions takes arguments from the other function, then it wont work unless function B is inside function A.
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
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
so everything work its just not creating a hitbox
** You are now Level 1! **
not creating?
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
i wanna use a getmarkerreachedsignal and just use hit events but im still learning
no
not creating or showing up
it doesnt exist in workspace?
do i have to make a hitbox for it to find?
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
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
how
you sound smart you wanna come fix this for commision?
only this?
yes the bugs in the combat it would be super swag
only hitbox thing?, aight i'll try