Hey, so I’m trying to make an event with Adonis to check when something is changed in the workspace and change the players admin level. I don’t know how to use MakePluginEvent. It says it there in the ExamplePlugin that you can use it but using find in all scripts doesn’t show anything about it in the MainModule.
I don’t know if this is still a valid way of doing it but you used to be able to access the events portion of the adonis services. The makepluginevent is something you can use to make a plugin (as the name suggests) instead of using the plugin scripts provided. If you are wanting to do what you are asking then using a standard event and a normal plugin is what you should be trying to do.
-- One script
service.Events.EventName:connect(function()
-- stuff
end)
-- Another script
-- If this script isn't part of an adonis plugin you can use the _G.Adonis API to get the adonis services.
-- More info on the _G.Adonis API can be found in the API modulescript located in the loader.
service.Events.EventName:Fire()
Edit: After checking, this is still in-fact a valid way of doing it. service.Events.EventName will create a new event, the events name will be whatever you decide to index service.Events with. In this case it would be “EventName”.
I believe you have to use the Access function within the adonis global table. Your access key is something you add in your settings module . You will also want to enable Service in Allowed_API_Calls.
local Service = _G.Adonis.Access(AccessKeyInSettingsModule, "Service") -- A list of other things you can access are found inside the adonis settings module.
Service.Events.EventName:Fire(...)
I Haven’t used adonis in a while so this could have been updated but upon quick glance at the settings module it seems plausible.
Do you have API access enabled in the settings module of the adonis loader? According to the API this is what you should be doing:
--_G.Adonis.Access(accessKey, serverSubTable)
-- - Returns a read-only version of a server subtable; allowing you to use all of it's functions
-- - Settings can be changed in the Settings module for what to allow access to and to change if scripts can read/write
settings.G_Access should be set to true and Service should be set to true aswell inside the settings.Allowed_API_Calls. This is the section you should be looking at:
If you have it set up properly it shouldn’t be returning nil, that being said Adonis hasn’t been updated in a while and the _G API might not even be working at this point. What is your goal exactly with what you are trying to create? You could probably use entirely plugins to accomplish what you are trying to make instead of having to access _G.
server = nil
service = nil
return function()
service.Events.Test.Event:Connect(function(message)
print(message)
end)
end
Seperate Server script accessing the Adonis API
local Players = game:GetService("Players")
repeat wait() until _G.Adonis
local Service = _G.Adonis.Access("MyKey", "Service")
local function HandlePlayer(Player)
Player.Chatted:Connect(function(Message)
Service.Events.Test:Fire(Message)
end)
end
for _, Player in pairs(Players:GetPlayers()) do
HandlePlayer(Player)
end
Players.PlayerAdded:Connect(HandlePlayer)