How do I fire a remote event when I activate a tool?

  1. I’m trying to make a tool that fires a remote event and prints something in the output when you activate the tool.

  2. When ever I click nothing happens. There is no errors either.

  3. I have tried everything i can think of!

Here is the script i have inside of a local script in the tool:

local equipped = false
script.Parent.Activated:Connect(function()

    equipped = true
    if equipped == true then
        print("KatanaEquipped")
game.ReplicatedStorage.Katana.KatanaEquip:FireServer()
    end
end) 

Please help me out.

Simple! I’ve done this all the time!

(But please note, a Script can handle Tool.Activated too)

So, it looks like the LocalScript is firing, but nothing is there to handle it. You need a script to handle the event of KatanaEquip. I believe it is RemoteEvent.OnClientEvent.

Server-Server communication can be done using a BindableEvent.

1 Like

So do I just add a normal script with KatanaEquip.OnClientEvent? I don’t think I really understand. Sorry.

Of course! I think you get it now. A RemoteEvent will communicate from Client to the Server, or from the Server to the Client, but the only catch is that you cannot return values since it is an event, which you won’t be using anyway.

local equipped = false
local replicated = game:GetServive("ReplicatedStorage")

script.Parent.Activated:Connect(function()
    equipped = true
    if equipped == true then
        print("KatanaEquipped")
        replicated:WaitForChild("Katana"):WaitForChild("KatanaEquip"):FireServer()
    end
end)

server

local replicated = game:GetServive("ReplicatedStorage")

replicated.Katana.KatanaEquip.OnServerEvent:Connect(function(plr)
    --do code
end)

Notice that you can always have remotes inside the tool itself.

1 Like

Ok, that did not work, i put the script in server script service and it still wont print anything or load the animation im trying to play inside the server script. I dont understand?

What’s the code for the server? The previous solution mentioned it should be like this:

Also, is the katana loading in the RemoteEvent properly, or is there an error in the output. If so, add a wait(2) before anything, in the local script.

There is no error at all. I can not figure this out, i have all the tools properties set right. I am so confused!

Alright, I’ll just cram a whole bunch of questions to ask yourself, all in one post!

Get ready:

Is the LocalScript running? Does the tool have a handle? If so, does the property say it needs a handle? Is the LocalScript calling the RemoteEvent? Is the RemoteEvent hooked up correctly? If so, does it actually do anything? Is the tool being cloned from somewhere, or is it just in the Backpack? Is the :WaitForChild("KatanaEquip") hanging? Is the :WaitForChild("Katana") hanging? If so, you need to add (assuming a folder) named Katana in ReplicatedStorage, then add a RemoteEvent inside, named KatanaEquip. Does the tool “manually activate”?

You don’t need to answer these questions, they are just for you to ask yourself.

1 Like

Everything is just where it should be, there is a folder and everything! Im just trying to fire a remote event with a tool.

I assume your tool doesn’t have a part called Handle while the tool’s RequiresHandle property is enabled?

1 Like