Trouble with BindableEvents

I have make a server script for a very simple knife but instead of dealing the damage on the knife’s script I am trying to pass the information over to another server script via a BindableEvent. Everything works well until the information got passed over to the other script, I have tried to fix it but I don’t know how.
Knife’s server script:

local DebounceTable = {}
local RS = game:GetService("ReplicatedStorage")
local BE = RS.ReviveBE

	if hitPart.Parent and hitPart.Parent:WaitForChild("Humanoid") then
		local playerCharacter = hitPart.Parent
		local player = game.Players:GetPlayerFromCharacter(playerCharacter)
		if player then
			if DebounceTable[player] == true then return end
			DebounceTable[player] = true
			print("Successfully fired the BindableEvent")
			DebounceTable[player] = nil
		print("Not a player")

ServerScript in ServerScriptService:

local RS = game:GetService("ReplicatedStorage")
local BE = RS.ReviveBE

	print("BindableEvent has recieved information")
	print("Player was hit:", playerThatWasHit)
	local Humanoid = playerThatWasHit.Character and playerThatWasHit.Character:FindFirstChild("Humanoid")
	if Humanoid then
		print("Got past the humanoid stage")
		print("Player is taking damage")

The second script is the one I am having trouble with. I have included prints to see where the code stops. I get an error where the “Local Humanoid” is located, saying “Humanoid is not a valid member of Players ‘Players’”. What I am trying to achieve is that once the knifes hitbox touches another player it fires the BindableEvent, then the BindableEvent needs to know what player got hit and apply the damage to them.

You are getting the Humanoid from the Parent of the Player, which is the Players Container? The Container that holds all the Player Instances?

1 Like

Should there be no Parent after “playerThatWasHit”?


The Player Instance has to be Parented somewhere, which is where Players comes in, where they were always at, the Parent of Players is game, and the Parent of game is nil (no value).

You are checking if the Humanoid Exists, but then you checked if the Parent of the Player (Players) had the Humanoid, which It doesnt, so this is all you need to do:

if Humanoid then

Which the Humanoid was already Found, you were just checking in a Diffrent place.

1 Like

Ok I replaced parent with character and it worked. I also tried your approach and it worked too.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.