Hello! I have lately been working on a group auto-rank system and for some reason when a RemoteEvent is fired, the module doesn’t catch it. I am not sure why and have run out of solutions. So, I came here to ask you!
My current module-script:
local server = require(game.ServerScriptService.Server)
local domain = 'painted-pixie.glitch.me' -- Make sure there is no http:// in here!
local key = 'mainpassone'
print("key")
local groupId = 3438171
local api = server(domain, key, groupId)
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr)
print("recieved")
local userId = plr.UserId
print("got")
api.promote(userId)
print("promoted")
end)
And of course, none of the prints are made. Please note, this is a ModuleScript so not sure if this affects anything. Also, this code is based off of a youtube video as I can’t figure out how any other auto-group-ranking things work.
I do rank management places and I don’t use a ModuleScript for handling remote events. I have the remote events just in a script in ServerScriptService. So try using just a script instead of ModuleScript for it and see if works.
EDIT: Pretty much take what you have above and place inside of a Script Instead of a ModuleScript.
It seemed to have fixed it not doing anything at all, thank you. Now, it says my require has invalid arguments. Usually require has a number but I thought this was possible too. Anyways, thanks!
You should be able to require a module this way, I’m not sure why you can’t. There’s nothing wrong with the code that I can see, unless ServerScriptService.Server isn’t a module script.
Have you read through and followed the tutorial step by step?
Also, the response from the server is an html file saying the error. The server wants json.
@ScriptedThunder That shouldn’t affect anything - a ModuleScript is just a way of importing foreign code into a script - unless there is an issue with the require arguments or return, changing from a ModuleScript shouldn’t affect anything, and will most likely just complicate things.
@Igotthemoney2212 I would strongly recommend not doing what you are doing right now:
Firstly, I hope your private key isn’t ‘mainpassone’ - if so, you shouldn’t post that here () and you should change it to at least a 256 bit key. Try using one of the “Fort Knox” passwords from this website: https://randomkeygen.com/ otherwise it will be incredibly easy for a malicious user to gain access to your API (especially since you have now posted the endpoint onto a public forum)
Secondly, how you have set up your promotion system means that any exploiter can immediately get promoted up to any rank below your bot account. You should try to set up some sort of authentication on the server, such as “has this user completed an application?” or “does this user have enough points for a promotion?”
Finally, your issue is because your web server is not responding to requests properly. Have you checked on your noblox-js server that it is starting up properly and responding to requests correctly? I personally would not use glitch as it is not really built for production applications - if you start handling lots of requests (i.e. your group grows very large) glitch won’t be able to handle the server throughput.
Point 1; I did change it once I posted this and am planning on changing it again.
Point 2; I currently just have it auto-rank when a user clicks a button so I could test it.
Point 3; I switched from glitch to heroku. Now the only problem is I don’t know what the Procfile should be, as it doesn’t specify in the tutorial. It’s currently set to
worker: node server.js