I want the hitbox to detect if the player is in front of me if they are blocking
local Hitbox = workspace:GetPartBoundsInBox(hrp.CFrame * CFrame.new(0,0,-3), Vector3.new(5,5,5))
local Hit = {}
for i,v in pairs(Hitbox) do
if v.Parent:FindFirstChild(“Humanoid”) and v.Parent ~= character and not Hit[v.Parent] then
Hit[v.Parent] = true
local targ = v.Parent
if targ:GetAttribute("Parrying") == true then
print("Hi")
Parried.Parent = targ.Humanoid
Parried:Play()
task.spawn(function()
character:SetAttribute("Stunned", true)
task.wait(0.7)
character:SetAttribute("Stunned", false)
end)
game.Debris:AddItem(Parried, Parried.TimeLength)
return
elseif targ:GetAttribute("Blocking") == true then
print("Yea")
return
end
targ.Humanoid:TakeDamage(5)
Punched:Play()
game.Debris:AddItem(Punched, Punched.TimeLength)
end
end
If you don’t know what lookvectors are ill explain it to you. Lookvectors are something we call “unit vectors” this just means it has a length of 1, sort of like unit rays. Like have you used vector3.Unit before? It’s like that sort of. So this is how you’d for example position a part 10 studs infront of its lookvector.
A module script is a script that can be accessed by other scripts. This makes them useful for storing values that operations are preformed on frequently, such as health, stun, and things you’d have in a fighting game since they can also have functions stored inside of them, preventing the need to copy-paste the same OnDamage function to every single weapon.
It’s not just one module that’s used globally (though that technically can be done, it’d be somewhat difficult to debug), every character would have their own modulescript for their stats.
Store variables in a much cleaner way than attributes.
Store a wider variety of variables than attributes, such as tables and newproxy()'s
Store functions that can be called, saving you from copy and pasting code.
The only downside is the fact it’s not replicated across server-client, but that is easily remedied with the use of remote events, if the client even needs to read those values at all.