I’m trying to make a tool that fires a remote event and prints something in the output when you activate the tool.
When ever I click nothing happens. There is no errors either.
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)
(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.
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.
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.
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.