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)