How do I detect when a player is holding a tool in a server script?

  1. What do you want to achieve?
    I am trying to fire a remote event when a player holds a certain tool.
  2. What is the issue?
    The output tells me that Character is not a valid member of Players, which I assume is because it isn’t in a local script.
  3. What solutions have you tried so far?
    I’ve looked in a lot of places and couldn’t find anything relevant to my problem, so I resorted here. This is my first post actually, so whether or not I’m doing this right is yet to be seen.

Down here is the code, I added the print to make sure it is actually firing, since I haven’t scripted the next part yet. Please do note I’m a beginner and don’t have much experience.

game.Players.Character.ChildAdded:Connect(function(tool)
	if tool:IsA("Tool") and tool.Name == "DEATH" then
	game.ReplicatedStorage.Death1:FireClient(tool)

	print("test")
end
end)

I just need someone to tell me what I can do to replace Characters or fix the script to work on a server side script.

Character isn’t a member of players, it’s a member of a PLAYER INSTANCE.
Also, you should put character in a variable using playeradded and then characteradded event, that way you don’t have it lagging behind and it instancing, do

game.Players.PlayerAdded:Connect(function(p)
  p.CharacterAdded:Connect(function(c)
    (code here)
  end)
end)
1 Like