Remote Event Not Being Received

Im trying to make it so if you click on someone with a tool and they have a knife, they get killed. Whenever I run it, the event fires, but the script in the server doesn’t receive it. I’ve tried bug fixing with other forums, however none of their solutions seem to be working.

LOCAL SCRIPT INSIDE TOOL

local tool = script.Parent

tool.Equipped:connect(function(mouse)     
	tool.Activated:connect(function()   
		if mouse.Target then
			local SelectedPlayer = mouse.Target.Parent
			if SelectedPlayer:FindFirstChild('Knife') and SelectedPlayer:FindFirstChild('Humanoid') then  -- checks if clicked player has a knife
				local Humanoid = SelectedPlayer:WaitForChild("Humanoid")
				local repStor = game:GetService("ReplicatedStorage")
				local killRemote = repStor:WaitForChild("KillRemote") --Requires a RemoteEvent named "KillRemote" to be childed under ReplicatedStorage
				local TargetHumanoid = mouse.Target.Parent
				
				killRemote:FireServer(TargetHumanoid) --Sends a message to activate the RemoteEvent
			print("worked")
			end
		end
	end)
end)

-----------------------------------------
Server Script
local repStor = game:GetService("ReplicatedStorage")
local killRemote = repStor:WaitForChild("KillRemote")

print("worked1")

game.ReplicatedStorage.KillRemote.OnServerEvent:Connect(function(TargetHumanoid)
	print("worked2")-- I need to now get the selected player from the other script and 
end)


3 Likes

Not sure if this is exactly what you’re asking, but it’s still important to note. On the server, once you get a remote event, the first parameter is the player, then the data from the client.

You should be something like:

game.ReplicatedStorage.KillRemote.OnServerEvent:Connect(function(player, TargetHumanoid)
-- run code from here
1 Like

yeah thanks, but still whenever I test the scripts in game it only shows the print from the local script and not any from the server script. :confused:

1 Like

Check the parent of the script, are you sure its serverscriptservice? Happens to me quite frequently

1 Like

Also just a tip, you dont have to put the tool.Activated inside the .Equipped event, becaude the activated event only fires when your holding your tool