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
script.Parent:WaitForChild("HitBox").Touched:Connect(function(hitPart)
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
BE:Fire(player)
print("Successfully fired the BindableEvent")
wait(2)
DebounceTable[player] = nil
else
print("Not a player")
end
end
end)
ServerScript in ServerScriptService:
local RS = game:GetService("ReplicatedStorage")
local BE = RS.ReviveBE
BE.Event:Connect(function(playerThatWasHit)
wait(0.5)
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")
playerThatWasHit.Parent.Humanoid:TakeDamage(30)
print("Player is taking damage")
end
end)
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.