Remote Event Giving Error

I’m trying to make a destroy tool but this error pops up:

Client

local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local remote = script.Parent:FindFirstChild("Destroy")

script.Parent.Activated:Connect(function()
	remote:FireServer(mouse.Target)
end)

Server

local remote = script.Parent:FindFirstChild("Destroy")

remote.OnServerEvent:Connect(function(player, mt)
	print("We got here, remote fired.")
	
	mt:Destroy()
end)

Error:

Players.funnyfunns.Backpack.Destroy Tool.ClientHandler:6: attempt to index nil with 'FireServer' 

From what it looks like, the remote event is in the client instead of replicated storage?

I think you gave it the wrong location if it’s giving you nil, try giving it the location of the RemoteEvent, which is located in the script that uses the OnServerEvent

Try using WaitForChild instead of FindFirstChild

1 Like

Place the remote event in Replicated storage.

It works now! I used :WaitForChild

1 Like

That’s good! And it would make sense why WaitForChild worked since it’s better to use that in this case if you know that the RemoteEvent will always be there