I am having a bit of trouble with the module. So, I created a simple melee combat. When I load in, the melee works fine however, when I reset then it breaks and no errors appear in the console. I would appreciate any help with this and thank you in advance!
Here is the local script:
--// SERVICES \\--
local players = game:GetService("Players")
local repStorage = game:GetService("ReplicatedStorage")
--// VARIABLES \\--
local combatTool = script.Parent
local hitboxModule = require(repStorage.RaycastHitboxV3)
local combatEvent = repStorage:WaitForChild("combatEvent")
local player = players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum, hrp = char:WaitForChild("Humanoid"), char:WaitForChild("HumanoidRootPart")
local rArm = char:FindFirstChild("Right Arm") or char:WaitForChild("Right Arm")
local armPoints = {
-- Center
Vector3.new(0, 0.5, 0),
Vector3.new(0, 0, 0),
Vector3.new(0, -0.5, 0),
-- Front Close
Vector3.new(-0.5, 1, -0.5), -- Top
Vector3.new(-0.5, 0, -0.5), -- Mid
Vector3.new(-0.5, -1, -0.5), -- Bottom
-- Front Far
Vector3.new(0.5, 1, -0.5),
Vector3.new(0.5, 0, -0.5),
Vector3.new(0.5, -1, -0.5),
-- Back Far
Vector3.new(0.5, 1, 0.5),
Vector3.new(0.5, 0, 0.5),
Vector3.new(0.5, -1, 0.5),
-- Back Close
Vector3.new(-0.5, 1, 0.5),
Vector3.new(-0.5, 0, 0.5),
Vector3.new(-0.5, -1, 0.5),
}
--// EVENTS \\--
local rArmInit = hitboxModule:Initialize(rArm, {char})
rArmInit:SetPoints(rArm, armPoints)
rArmInit.OnHit:Connect(function(hit, hum)
if hum and hum.Health > 0 then
combatEvent:FireServer("punch", hit, hum)
end
end)
combatTool.Activated:Connect(function()
rArmInit:HitStart()
wait(.3)
rArmInit:HitStop()
end)
Server Script:
--// Services \\--
local repStorage = game:GetService("ReplicatedStorage")
--// Variables \\--
local combatEvent = repStorage:WaitForChild("combatEvent")
--// Events \\--
combatEvent.OnServerEvent:Connect(function(player, action, info, info2)
local char = player.Character
local hum, hrp = char:FindFirstChild("Humanoid"), char:FindFirstChild("HumanoidRootPart")
if action == "punch" then
local hit, ehum = info, info2
if hum and hum.Health > 0 and ehum and ehum.Health > 0 then
ehum:TakeDamage(10)
end
end
end)