Remote Event not working?

So I have a RemoteEvent in RepliactedStorage> Events> Use> EquipTrail

When a button is pressed- In your inventory:
LocalScript:

--[[ Variables ]]--
local RepliactedStorage = game:GetService("ReplicatedStorage")
local EquipEvent = RepliactedStorage:WaitForChild("Events"):WaitForChild("Use"):WaitForChild("EquipTrail")

script.Parent.MouseButton1Down:Connect(function()
    local Name = script.Parent.Parent.Name
    EquipEvent:FireServer(Name)
    print("Made it here") -- To see if the script works and it does!
end)

The Button Works because in the Output is says Made It here

Script in ServerScriptService:

--[[ Events ]]--
local EquipTrailEvent = RepliactedStorage:WaitForChild("Events"):WaitForChild("Use"):WaitForChild("EquipTrail")

--[[ Event Fired By Client]]--
EquipTrailEvent.OnServerEvent:Connect(function(player, name)
    print("Server: Connected to the event!") -- Doesn't print // Nothing happens
    if player.CurrentTrail.Value == name then
    	Item.UnEquipTrail(player, name)
    else
    	Item.EquipTrail(player, name)
    end
end)

For Some reason this doesn’t work, the only thing in the output is Made it here, So there are no errors.

Is there an obvious mistake I made?

Thanks in advanced :smiley:

The script could be hanging on the server side, can you put a print before the OnServerEvent?

--[[ Event Fired By Client]]--
print("Made it here?")
EquipTrailEvent.OnServerEvent:Connect(function(player, name)
	print("Server: Connected to the event!") -- Doesn't print // Nothing happens
	if player.CurrentTrail.Value == name then
		Item.UnEquipTrail(player, name)
	else
		Item.EquipTrail(player, name)
	end
end)
1 Like

I forgot to mention this is in a ModuleScript; I have other events in here and they work fine.

That shouldn’t make a difference, please just put that print in and see if it outputs.

It doesn’t print anything. I think it does matter because a module script only works when it is required, surely?

Are you requiring the modulescript? Because no code will run inside of it until you do. Including that event.

I have other events and they work in a module script. Also I am requiring the script but that’s a whole different system.

Essentially, What happens is that When a player has purchased a trail from the shop, it will add it to the inventory. Once it’s there they press on it to equip it.

If it’s not printing that means the code is not running, and that your event code is never ran. Therefore it cannot receive signals from events.

Is EquipTrailEvent the Remote Event name? Based on the rest of the code, it isn’t. Try showing the path to the event in the Server script.

Sorry, I didn’t put that it the main thread.
In the ServerSided Script it has a variable named:

--[[ Events ]]--
local EquipTrailEvent = RepliactedStorage:WaitForChild("Events"):WaitForChild("Use"):WaitForChild("EquipTrail")

Not sure if this affects it but “RepliactedStorage” is incorrect.

That would be erroring if it was, he is getting no errors in output. So likely this is just a typo.

Yeah It’s just a typo. My bad.

Do you think this could be a problem on Roblox’s End?
Highly likely that its not, but a chance.

As I said, that listener for that event is not getting run. Since that isn’t printing it isn’t running, I think you’ll find that if you just put that in a regular serverscript the code will work fine.

ModuleScripts do NOT run their code unless they have been require()ed

2 Likes

To add on to @M9_Sigma’s statement. Try placing a print statement before the event connection to test if it’s running.

We’ve already tested this, it did not print.

I have required all of the module scripts, I have listeners in other scripts that work. I’ll try putting it in a normal Script.

1 Like

The fact that print() isn’t printing anything means the compiler cannot reach that part of the script. It is either not running at all or it is hanging somewhere.

1 Like

Where was the print statement placed? If it was just before the connection try moving it to before EquipTrailEvent is assigned.

1 Like

I fixed the issue, It was my mistake. I was requiring the wrong module script. Thank you @M9_Sigma and @Arcental. I will mark @M9_Sigma comment as Solution.