Boolean must be a boolean value

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Make this group accepter work via .js
  2. What is the issue? Include screenshots / videos if possible!
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve tried so hard, and no solutions at all…

ServerScriptService:

local HttpService = game:GetService("HttpService")
local Server = require(script.Server)
local groupID = 52XXXXX
local Accept = game.ReplicatedStorage.AcceptJoinRequest.Accept

game.ReplicatedStorage.AcceptJoinRequest.OnServerEvent:Connect(function(player, Accept)
		if Accept then
		print("yes")
		Server.HandleJoinRequest(groupID, player.Name, player.UserId, Accept) -- Line the error is coming from
	end
end)

Can we see the function in the module script?

1 Like

It is connecting the player from a serverscript when the player joins.

This has worked quite perfectly for my other method, however, this time I’m trying too make it so that when someone joins the game, they get automatically accepted into the group.


local Server = {}

local HttpService = game:GetService("HttpService")

local Configs = require(script.Parent.Configs)
 
local function Request(Function, RequestBody)
	
	--Before sending the request, add our auth_key to the body
	RequestBody["auth_key"] = Configs.AUTH_KEY
	
	local response = HttpService:RequestAsync(
		{
			-- The website to send the request to. Function is the extended part of the URL for specific functions.
			-- In this case, Function = 'GroupShout'
			-- Example: 
			--	"Configs.BaseUrl..Function" would be equal to: http://test-app.glitch.me/GroupShout
					
			Url = Configs.BaseUrl..Function, 

			-- The request method (all of ours will be POST)
			Method = "POST",

			-- We are sending JSON data in the body
			Headers = {
				["Content-Type"] = "application/json"
			},
			-- The body of the request containing the parameters for the request
			Body = HttpService:JSONEncode(RequestBody)
		}
	)
 
	if response.Success then
		print("Status code:", response.StatusCode, response.Body)
		print("Response body:\n", response.Body)
		
		return response.Body
	else
		print("The request failed:", response.StatusCode, response.Body)
		return response.Body
	end
end

Server.Promote = function(GroupId, UserId)
	assert(typeof(GroupId) == "number", "Error: GroupId must be an integer") -- Throw error if GroupId is not an integer
	assert(typeof(UserId) == "number", "Error: UserId must be an integer") -- Throw error if UserId is not an integer

	local Body = {
		Group = GroupId;
		Target = UserId;
	}
	
	 -- pcall the function 'Request', with arguments 'Promote' and Body
	local Success, Result = pcall(function()
	    return Request('Promote', Body)
	end)
	
	print(Result)
end

Server.Demote = function(GroupId, UserId)
	assert(typeof(GroupId) == "number", "Error: GroupId must be an integer") -- Throw error if GroupId is not an integer
	assert(typeof(UserId) == "number", "Error: UserId must be an integer") -- Throw error if UserId is not an integer
	
	local Body = {
		Group = GroupId;
		Target = UserId;
	}
	
	local Success, Result = pcall(function()
	    return Request('Demote', Body)
	end)
	
	print(Result)
end

Server.SetRank = function(GroupId, UserId, RankId)
	assert(typeof(GroupId) == "number", "Error: GroupId must be an integer") -- Throw error if GroupId is not an integer
	assert(typeof(UserId) == "number", "Error: UserId must be an integer") -- Throw error if UserId is not an integer
	assert(typeof(RankId) == "number", "Error: RankId must be an integer") -- Throw error if RankId is not an integer

	local Body = {
		Group = GroupId;
		Target = UserId;
		Rank = RankId;
	}
	
	local Success, Result = pcall(function()
	    return Request('SetRank', Body)
	end)
	
	print(Result)
end

Server.HandleJoinRequest = function(GroupId, PlayerUsername, Boolean)
	assert(typeof(GroupId) == "number", "Error: GroupId must be an integer") -- Throw error if GroupId is not an integer
	assert(typeof(PlayerUsername) == "string", "Error: PlayerUsername must be a string") -- Throw error if PlayerUsername is not a string
	assert(typeof(Boolean) == "boolean", "Error: Boolean must be a boolean value") -- Throw error if Boolean is not a boolean value

	local Body = {
		Group = GroupId;
		Username = PlayerUsername;
		Accept = Boolean; -- true or false
	}
	
	local Success, Result = pcall(function()
	    return Request('HandleJoinRequest', Body)
	end)
	
	print(Result)
end

Server.GroupShout = function(GroupId, ShoutMessage)
	assert(typeof(GroupId) == "number", "Error: GroupId must be an integer") -- Throw error if GroupId is not an integer
	assert(typeof(ShoutMessage) == "string", "Error: ShoutMessage must be a string") -- Throw error if ShoutMessage is not a string

	local Body = {
		Group = GroupId;
		Message = ShoutMessage;
	}
	
	local Success, Result = pcall(function()
	    return Request('GroupShout', Body)
	end)
	
	print(Result)
end

return Server

Specifically looking at this area:

Server.HandleJoinRequest = function(GroupId, PlayerUsername, Boolean)
	assert(typeof(GroupId) == "number", "Error: GroupId must be an integer") -- Throw error if GroupId is not an integer
	assert(typeof(PlayerUsername) == "string", "Error: PlayerUsername must be a string") -- Throw error if PlayerUsername is not a string
	assert(typeof(Boolean) == "boolean", "Error: Boolean must be a boolean value") -- Throw error if Boolean is not a boolean value

	local Body = {
		Group = GroupId;
		Username = PlayerUsername;
		Accept = Boolean; -- true or false
	}
	
	local Success, Result = pcall(function()
	    return Request('HandleJoinRequest', Body)
	end)
	
	print(Result)
end

There’s nothing wrong with the module scripting at all.

You’re passing the userid into the boolean parameter.

Yes, but I’m required to have the userid or else it will warn me saying I need the players userid?

Then add a parameter for the userid.

Required argument “userid” is missing pops up on my Virtual Private Server, so therefore I added in a player.UserId

However, I will get the boolean error if I add in player.UserId

This line is sending the function four parameters in which player.UserId is a integer. Your function only is requiring three parameters and the last one is not for the Boolean. Also is Accept a BooleanValue or something else?

Yes, and if I put .Value at the end, it’ll give me the same error I believe.

image

That’s because you’re passing an integer into a boolean value. Add another parameter for the userId and pass the userId into it.

1 Like

Have you tried adding the parameter though?

Server.HandleJoinRequest = function(GroupId, PlayerUsername, UserID, Boolean)

Server.HandleJoinRequest = function(GroupId, PlayerUsername, UserID, Boolean) does nothing

It doesn’t accept me into the group if I join the game.

However, that would get rid of the error.

game.ReplicatedStorage.AcceptJoinRequest.OnServerEvent:Connect(function(player, Boolean)
Server.HandleJoinRequest(groupID, player.Name, player.UserId, Boolean)

I’ve tried changing to that, and I still get the same error.