How to return a Boolean value with ModuleScript?

Well, I was recently forced to learn ModuleScript, and since I’m new to this, I don’t know how to use it. I wanted that when calling the ModuleScript, after all the function of this that it returns false so that the script that called it takes it so that the debounce is deactivated

LocalScript:

local ChangeDataFPSAndPing  = require(script:WaitForChild("ModuleScript"))
local Debunce_fps = false

local Data = {
	FPS_and_Ping = {
		MostrarFps:WaitForChild("Abrir");
		MostrarPing:WaitForChild("Abrir")
	};
}
Data["FPS_and_Ping"][1].MouseButton1Click:Connect(function()
	if not Debunce_fps then
		Debunce_fps = true
		local Profiles = ChangeDataFPSAndPing:FPS_or_Ping(Data.FPS_and_Ping[1])
		Debunce_fps = Profiles
	end
end)

ModuleScript:

local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Change_configuration = ReplicatedStorage:WaitForChild("ConfiguracionGeneral"):WaitForChild("Change_configuration")

local Data = {}

function Data:FPS_or_Ping(GetTypeFunction)
	if GetTypeFunction.Take.Value  == 'True' then
		GetTypeFunction.Icon:TweenPosition(UDim2.new(0.85, 0, 0.5, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.7, true)
		TweenService:Create(GetTypeFunction.Icon, TweenInfo.new(1), {ImageColor3 = Color3.new(0.501961, 1, 0.501961)}):Play()
		TweenService:Create(GetTypeFunction.Icon, TweenInfo.new(1), {BackgroundColor3 = Color3.new(0.407843, 0.701961, 0.317647)}):Play()
		TweenService:Create(GetTypeFunction, TweenInfo.new(1), {BackgroundColor3 = Color3.new(0.317647, 0.541176, 0.313725)}):Play()
		GetTypeFunction.Icon.Image = "http://www.roblox.com/asset/?id=6652973166"
		wait(0.5)
		if GetTypeFunction.Parent.Name == "MostrarFps" then
			Change_configuration:FireServer("FPS", "Enabled")
		elseif GetTypeFunction.Parent.Name == "MostrarPing" then
			Change_configuration:FireServer("Ping", "Enabled")
		end
		GetTypeFunction.Take.Value = "False"
	elseif GetTypeFunction.Take.Value == "False" then
		GetTypeFunction.Icon:TweenPosition(UDim2.new(0.15, 0, 0.5, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.7, true)
		TweenService:Create(GetTypeFunction.Icon, TweenInfo.new(1), {ImageColor3 = Color3.new(1, 0.537255, 0.537255)}):Play()
		TweenService:Create(GetTypeFunction.Icon, TweenInfo.new(1), {BackgroundColor3 = Color3.new(0.509804, 0.509804, 0.509804)}):Play()
		TweenService:Create(GetTypeFunction.Button, TweenInfo.new(1), {BackgroundColor3 = Color3.new(0.529412, 0.313725, 0.313725)}):Play()
		GetTypeFunction.Icon.Image = "http://www.roblox.com/asset/?id=6652972833"
		wait(0.5)
		Change_configuration:FireServer("Tree", "Disable")
		if GetTypeFunction.Parent.Name == "MostrarFps" then
			Change_configuration:FireServer("FPS", "Disable")
		elseif GetTypeFunction.Parent.Name == "MostrarPing" then
			Change_configuration:FireServer("Ping", "Disable")
		end
		GetTypeFunction.Take.Value = "True"
	else
		warn("StringValueObject.Value is not \"True\" or \"False\"")
		wait(0.5)
	end
	return false
end

return Data
local module = true

return module

ModuleScripts can return a single value of any of the available primitive types.

I have a question regarding the ModuleScript, when a Local Script calls them, will it be executed only on the client?

Yes, modulescript execution context is thr same as the script rhat required it

1 Like

Yeah, what the previous post stated, if a local script requires a ModuleScript then that ModuleScript acts client-side whereas if a server script requires a ModuleScript then that ModuleScript acts server-side.

1 Like