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.
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)
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.
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
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.
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.