Remote Event Won't Fire

Hey there!
I’m trying to make a script that fires a remote event when a player uses a certain tool. But I want it only to fire for that player. I don’t know why it won’t work, and here’s my script:

local tool = script.Parent
local animation = tool.Animation
local Players = game:GetService("Players")
local player = Players.LocalPlayer

tool.Activated:Connect(function()
	local Character = tool.Parent
	local Humanoid = Character.Humanoid
	
	local AnimationTrack = Humanoid:LoadAnimation(animation)
	AnimationTrack:Play()
	game.ReplicatedStorage.HealthEvent:FireClient(player)
	wait(2.2)
	tool:Destroy()
end)

Is this a server or client script?

This is in a server script. It’s inside of a tool.

remote:FireClient() can only be used on the server, if you want to send data to the server from your client you should do remote:FireServer()

Also, you don’t need to include the Player in the arguments because the player that fired the remote is automatically passed as the first argument on the server

Players.LocalPlayer doesn’t exist on the server.

This is the server firing to the client. The local script isn’t giving any errors.

Players.LocalPlayer is nil on the server; you can only access it on the client.

1 Like

I’m having mixed emotions here!

Anyway, you could probably just do

local tool = script.Parent
local animation = tool.Animation
local Players = game:GetService("Players")

tool.Activated:Connect(function()
	local Character = tool.Parent
	local Humanoid = Character.Humanoid
    local player = Players:GetPlayerFromCharacter(Character) -- get player from character method on the server
	
	local AnimationTrack = Humanoid:LoadAnimation(animation)
	AnimationTrack:Play()
	game.ReplicatedStorage.HealthEvent:FireClient(player)
	wait(2.2)
	tool:Destroy()
end)