In case you didn’t know the module that I’m referring to: Raycast Hitbox 4.01: For all your melee needs! - #521 by TeamSwordphin
How would you make a functioning sword that is reliable with this module? I tried doing this method, firing the remote from a local script inside a sword. However, it does not work, and I think I found the reason.
Even tho I passed in the ignore argument in local RaycastHitBox:Initialize(handle, dontDamage), the newHitBox.OnHit still fires, picking up the humanoid that is told to be ignored, then not allowing any other humanoids to be detected as it can only damage one humanoid at a time. When I take out the ignore argument, the newHitBox.OnHit actually fires, which it does not when the ignore argument is left in RaycastHitbox:Initialize.
I also noticed when I put the sword in starter pack, some reason the issue is solved, or if I give the player the sword early on in the game, like 20 seconds in (not when the player is added)
Help would be appreciated I am struggling greatly with this issue
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local remoteData = game:GetService("ServerStorage"):WaitForChild("RemoteData")
local SwordDamage = require(ReplicatedStorage.Modules.SwordDamage)
local RaycastHitbox = require(ReplicatedStorage.Modules.RaycastHitbox)
local SwordRaycastPositions = require(ReplicatedStorage.Modules.SwordRaycastPositions)
local cooldown = require(ReplicatedStorage.Modules.Cooldown).cooldownValue
local humanoidsKilled = {}
ReplicatedStorage.Remotes.OnSwing.OnServerEvent:Connect(function(player, handle)
local playerTeam = nil
local playerToDamage = nil
if remoteData[player.Name].SwingHandlingDebounce == true then return end
local debounce = remoteData[player.Name].SwingHandlingDebounce
if not debounce.Value then
print("hello1")
debounce.Value = true
local character = player.Character or player.CharacterAdded:Wait()
local dontDamage = {character}
local damage = require(ReplicatedStorage.Modules.SwordDamage)[handle.Parent.Name]
local newHitBox = RaycastHitbox:Initialize(handle, dontDamage)
newHitBox:SetPoints(handle, SwordRaycastPositions[handle.Parent.Name])
newHitBox.OnHit:Connect(function(hit, humanoid)
--just for test purposes on dummies
humanoid:TakeDamage(10)
--local playerTeam = player.Team
--local playerToDamage = Players:GetPlayerFromCharacter(humanoid.Parent)
--if playerToDamage ~= nil then
-- print(player.Team)
--if tostring(playerToDamage.Team) == tostring(player.Team) then
-- print("DO NOT DAMAGE")
--elseif tostring(playerToDamage.Team) ~= tostring(player.Team) then
-- print("DAMAGE, THEY ARE THE ENEMY")
-- humanoid:TakeDamage(damage)
--end
--end
-- local leaderstats = player.leaderstats
--local kills = leaderstats.Kills
-- local enemyTeam = nil
-- local playerTeam = player.Team
--[[if table.find(humanoidsKilled, humanoid) == nil and humanoid.Health <= 0 then
table.insert(humanoidsKilled, humanoid)
kills.Value = kills.Value + 1
elseif table.find(humanoidsKilled, humanoid) == nil and humanoid.Health >= 0 then
table.remove(humanoidsKilled, humanoid)
end]]
end)
newHitBox:HitStart()
wait(cooldown)
newHitBox:HitStop()
debounce.Value = false
end
end)