I have tried using this module script I found from the developer forums called “Raycast Hitcast Module” with a tool and have tried to fix the attacking by using a remote event to fix the “pseudo attack”. However, it says attempt to index nil with Connect and I don’t understand why. I have tried searching across posts with the same error but none have occurred to me that I realized my error.
Additionally, the error said that it had occurred at line 4.
I think the issue might be with the parameters but I am still not sure.
Here’s the RemoteEvent I used so the tool actually attacks people when being near people instead of only showing the damage done to the attacker:
local RemoteEvent = game.ReplicatedStorage.SwordAttack
RemoteEvent.OnServerEvent:Connect(function(player, RaycastHitbox, hitbox, animationTrack, damage)
hitbox.OnHit:Connect(function(hit, humanoid)
print(hit.Name)
humanoid:TakeDamage(damage)
end)
animationTrack:Play()
hitbox:HitStart()
wait(1.7)
hitbox:HitStop()
player.PlayerGui.RunningMechanism.Disabled = true
end)