How to edit this script to use it

Hello everyone how are you?

--// Services
local HttpService = game:GetService("HttpService");

local RocketBots = {}
RocketBots.__index = RocketBots;

--// Creates a bot object
function RocketBots.new(loaderId)
	local BotObject = setmetatable({}, RocketBots);
	
	BotObject.id = loaderId
	
	return BotObject
end

--// Enviornment
local apiBase = "https://roblox-rocketapps.bloxtech.tech/roblox/bots"

local function http(loaderId, endpoint, method, body)
	if (body) then
		body = HttpService:JSONEncode(body)
	end
	
	local success, message = pcall(function()
		local newURL = apiBase .. '/' .. loaderId .. endpoint
		
		local Response = HttpService:RequestAsync({
			Url = newURL,
			Method = method,
			Headers = {
				["Content-Type"] = "application/json"  -- When sending JSON, set this!
			},
			Body = body
		});
				
		return HttpService:JSONDecode(Response.Body)
	end)
	
	
	if (not success) then
		return {success = false, response = message}
	else
		return message;
	end
end

--// Functions for the bot object.
function RocketBots:GetInfo()
	return http(self.id, '/', 'GET')
end

function RocketBots:GetJoinRequests()
	return http(self.id, '/getjoinrequests', 'GET')
end

function RocketBots:Shout(message)
	return http(self.id, '/shout', 'POST', {msg = message})
end

function RocketBots:MessageUser(userId: string, subject: string, message: string)
	return http(self.id, '/messageuser', 'POST', { ["userId"] = userId, ["subject"] = subject, ["message"] = message })
end

function RocketBots:ApproveJoinRequest(userId: string)
	return http(self.id, '/approvejoinrequest', 'POST', { ["userId"] = userId })
end

function RocketBots:DeclineJoinRequest(userId: string)
	return http(self.id, '/declinejoinrequest', 'POST', { ["userId"] = userId })
end

function RocketBots:RankInGroup(userId: string, rank: string)
	return http(self.id, '/rankingroup', 'POST', { ["userId"] = userId, ["rankId"] = rank })
end

function RocketBots:Exile(userId: string)
	return http(self.id, '/exile', 'POST', { ["userId"] = userId})
end

return RocketBots

How do I use this script its a module script so do I put it inside a normal script? also what would i put in the normal script to change the rank?

I am making it so that once a player says /role (rolenumber) then it changes their role. I think I may be able to make the chat script but if anyone has any tips please reply with it such as how i would get player id from which player said it.

Btw i dont know if this is in the right topic if it isnt please tell me which one to put it in so i can move it later but its scripting help so i thought it would probably go here.

You have to use require(pathToModuleScript) in a module script, like the following:

There you go:

local pathToModule = require(--Insert the path to your module here)

game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
if string.find(msg, "/role") then
local args = string.split(msg, " ")
local playerToRank = plr.UserId
local chosenRank = args[2]
-- Do the code you need here to rank the person using the playerToRank variable.
end)
end)

Edit: To my vision, you module script doesn’t offer ranking services, consider using another module perhaps?

2 Likes

does the below code not work?

function RocketBots:RankInGroup(userId: string, rank: string)
    	return http(self.id, '/rankingroup', 'POST', { ["userId"] = userId, ["rankId"] = rank })
    end