like the titles says how to add values to a module script that can be inside and outside its table
Uh what does that mean?
I have a feeling you mean something like dis:
-- Module script code
local module = {}
module.Cool = true
-- you can also access this value in the module any time you want by doing
module.Cool -- this would give you true, as thats what we set it as
return module
-- other scripts
local module = require(PathToModule)
print(module.Cool) -> true
what the skibidi do you even mean??
like…
local module = {
BALLS = {
SOME_VALUE = true
}
}
is this what you mean?? i am very confused,
i mean adding values from either local or server sides into a module script
(
what the skibidi
(this generation needs truly a savior…)
i mean adding values from either local or server sides into a module script
i think you are somehow able to create a new data structure inside module scripts, don’t quote me o nthat
idk how to achieve it though, sorry
these scripts add a value called InsideTable and OutSideTable to your module
local module = {}
module.InsideTable = "Inside The Table" -- create a value called InsideTable
module.OutsideTable = "Outside The Table" -- create a value called OutsideTable
return module
or this
local module = {
InsideTable = "Inside The Table" ,
OutsideTable = "Outside The Table"
}
return module
what the skibidi do you mean? like running a function in a module script that has values or values that are children of the module script?
i guess im talking to an ai…
no outside table like outside the module table and inside is inside it and want to add them from local or server script
changes made in a module cannot replicate to the server/client
what you can do if you want to send a value is to use remote events/remote functions
you can search about remote events if you want to do that
I’m not sure I understand what you’re asking lol
If you make them outside of the module table, they won’t be accessible from outside the module. But, you could do something like this…
local module = {}
local otherValues = {} --table to hold other values
function module.AddOutsideValue(key: any, value: any)
otherValues[key] = value
end
function module.foo()
otherValues.SomeKey --etc. You can use these outside values within the module.
end
function module.RetrieveOtherValue(key: any) --example method to retrieve them
return otherValues[key]
end
return module
--outside the module
local module = require(--[[path to module here]])
module.AddOutsideValue("SomeKey", 3)
print(module.SomeKey) --> nil
print(module.RetrieveOtherValue("SomeKey")) --> 3
This must be done on the same side of the client-server boundary.
Why do you want to do this, though?
like:
local module = {}
module.Teeth = 15
return module
-- somewhere else
local module = require(ModuleHere)
module.Teeth += 5
print(module.Teeth) -> 20
I think a little more context would help.
just make them local but if you could give us the script you’re working with or whatever i think that would help
ModuleScript
local module = {}
module.Inside = 10
function module.Add(Outside)
module.Inside = module.Inside + Outside
return module.Inside
end return module
Script
local mod = require(????.ModuleScript)
mod.Add(20)
print(mod.Add(20))
sorry guys it seems that i havent clarifed my problem but i ve found the solution
–module script
local mod = {}
return mod
server script
mod = require() --- requiring the module script
mod.addsomething = {}
print(addsomething)
i ve tested it and it worked thanks for the help now what i want is to do the same but add a value outside the mod script