Remote event isnt being fired?

I have some code that is supposed to fire a remote event once you click while holding a tool, but nothing is happening. Can someone help?

Server Script Code:

local RS = game:GetService("ReplicatedStorage")
local event = RS:WaitForChild("iPodEvent")

local Rig = workspace:WaitForChild("L1Rig")

local SS = game:GetService("SoundService")

local Hey = SS:WaitForChild("Hey")
local NoWorries = SS:WaitForChild("NoWorries")
local IDo = SS:WaitForChild("IDo")

event.OnServerEvent:Connect(function(player)
	print("event fired")
	
	Rig.HumanoidRootPart.CFrame = Vector3.new(-23.502, 15.446, 41.972)
	
	wait(3)
	
	TweenService:Create(Rig.Head, TweenInfo.new(1), {Orientation = CFrame.lookAt(player)}):Play()
	
	Hey:Play()
	wait(3)
	IDo:Play()
	wait(2)
	NoWorries:Play()
	wait(3)
	
	TweenService:Create(Rig.Head, TweenInfo.new(1), {Orientation = Vector3.new(0, 90, -0)}):Play()
end)

Client Code (inside of the tool):

local player = game.Players.LocalPlayer
local tool = script.Parent

local RS = game:GetService("ReplicatedStorage")
local event = RS.iPodEvent

tool.Activated:Connect(function()
	event:FireServer()
end)
2 Likes

Are you receiving any error from the output?
Also, if the event is not being fired, perhaps it means there is a bug in your script which you have to debug it.
So the first thing you want to do is to make sure what script contains that bug.
Start to fire the event manually to check the server script and ensure it works well, if you saw any bugs on server script, solve it.
Second thing you want to do is to do the same to local script, go ahead and put print() in each statement of your script and find out which part is not working.

None.

character limit hehehehe

And a quick question, how do I manually fire a remote event? I haven’t really heard of that.

It’s really simple, you just fire it.
Make a local script and fire it with no conditions.
Like this:

local rudeEvent = game:GetService("ReplicatedStorage"):WaitForChild("RudeEvent")

rudeEvent:FireServer()
print("Fired the event.")

You know, basically, put no condition and just fire it.
So how does this help you?
Perhaps you want to find out what script is not listening to you, right?
Fire it and ensure that everything on your Server Script is working well.

Well, I put a debug in the local script, and it’s seems the issue is that the tool is not being activated at all.

Exactly, so our problem is the Local Script.
So you put a print on Activated Function and receiving no report?
Then you’re actually gonna focus now on the tool.
Make sure to check if the tool variable is actually true, like you’re addressing it correctly to the script.

Hm, maybe the tool isn’t loading in fast enough. I might do a :WaitForChild

Can you provide me an image of your Studio Explorer?
So I can see what is where basically.

image

That image shows that the tool is in ServerStorage, and it’s meant to. I have some code that makes the Backpack the parent once touching an invisble sensor.

local iPodSensor = workspace:WaitForChild("IPodSensor")

local ServerStorage = game:GetService("ServerStorage")
local iPod = ServerStorage:WaitForChild("iPod")

local TweenService = game:GetService("TweenService")

local debounce = false

game.Players.PlayerAdded:Connect(function(player)
	iPodSensor.Touched:Connect(function(hit)
		if debounce == false then
			debounce = true
			
			if player then
				local clone = iPod:Clone()

				clone.Parent = player.Backpack
			end
			
			wait(300)
			
			debounce = false
			
		elseif debounce == true then
			return
		end
	end)
end)

local RS = game:GetService("ReplicatedStorage")
local event = RS:WaitForChild("iPodEvent")

local Rig = workspace:WaitForChild("L1Rig")

local SS = game:GetService("SoundService")

local Hey = SS:WaitForChild("Hey")
local NoWorries = SS:WaitForChild("NoWorries")
local IDo = SS:WaitForChild("IDo")

event.OnServerEvent:Connect(function(player)
	print("event fired")
	
	Rig.HumanoidRootPart.CFrame = Vector3.new(-23.502, 15.446, 41.972)
	
	wait(3)
	
	TweenService:Create(Rig.Head, TweenInfo.new(1), {Orientation = CFrame.lookAt(player)}):Play()
	
	Hey:Play()
	wait(3)
	IDo:Play()
	wait(2)
	NoWorries:Play()
	wait(3)
	
	TweenService:Create(Rig.Head, TweenInfo.new(1), {Orientation = Vector3.new(0, 90, -0)}):Play()
end)

So Overall
The tool successfully gets into the player inventory, but the problem is when using it, it won’t fire the remote event.
Let me head to the studio and make a similar thing as you are doing.
I let you know once done.

Appreciate it greatly.

character limit

Are you trying to do .Equipped ? instead of .Activated (maybe that can be the point)

I tried wrapping .Equipped inside of .Activated and it didn’t work. If I removed .Activated, it just won’t work since if it’s not being Activated… then well obviously it won’t work.

That means that “.Activated” part is not working properly. I guess all you need to do is changing that. What are you trying to do? When you click, its teleporting you then plays some sounds?

When you click, it changes a rig’s CFrame and some sounds play, so pretty much yeah.

Okay, so I made what you’re trying to do very simple.
Tool Giver Script:

local Tool = game:GetService("ServerStorage"):WaitForChild("ClassicSword")
script.Parent.Touched:Connect(function(Hit)
	if Hit.Parent:FindFirstChild("Humanoid") then
		local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
		if Player.Backpack:FindFirstChild("ClassicSword") then
			Player.Backpack:FindFirstChild("ClassicSword"):Destroy()
			Tool:Clone().Parent = Player.Backpack
		else
			Tool:Clone().Parent = Player.Backpack
		end
	end
end)

And the Server Script:

local Remote = game:GetService("ReplicatedStorage"):FindFirstChild("Remote")

Remote.OnServerEvent:Connect(function()
	print("Remote got the fire signal!")
end)

And the Tool Script:

local Tool = script.Parent
local Remote = game:GetService("ReplicatedStorage"):FindFirstChild("Remote")

Tool.Activated:Connect(function()
	print("Tool activated! Sending signal.")
	Remote:FireServer()
end)

And it worked!

So the point

It is clear as daylight that the error is your tool variable.
The script does not identify that as a TOOL.
So you could get details of that variable? Try hanging out with it, do prints and get details to see what’s wrong with that variable.

2 Likes

What about trying that?

local player = game.Players.LocalPlayer
local getmouse = player:GetMouse()
local Tool = script.Parent

Tool.Equipped:Connect(function(Mouse)
	Mouse.Button1Down:Connect(function()
		event:FireServer()
	end)
end)


Just change tool’s code with that.

As he mentions, the equipped function does not also work.
So if that doesn’t work, it’s pointless to use the Mouse function.

But he putted it inside of .Activated. if .Activated can’t work then, how can the code run .Equipped part.
(Maybe it was a spelling mistake idk maybe he tried to say “instead of”)