Attempt to index nil with Connect

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)
1 Like

Where did you get the “OnHit” event? It isnt an event that occurs with parts or humanoids in the api.
Did you mean “hitbox.Touched:Connect…”

The OnHit event is located from the module script which is “RaycastHitbox,” so in short terms, no it’s not hitbox.Touched.

I think we obviously need the other end. This is the server, so what is it being sent from?

(also side note - I noticed you’re sending in a hitbox from the client…isn’t that a little dangerous? What if an exploiter sends in a HUGE hitbox? You’re just gonna let them?)

Sorry about that, but in my eyes, it’s really the only way for me to send a signal since I always thought that Tool.Activated only fired in local scripts.