I assume you want to store and retrieve values from a modulescript,
A modulescript is in essence just a script that executes once per lua environment and is accessible by all scripts in that environment. (with lua environment i meant client (localscripts) ans server (scripts) )
If you require (for the first time in that lua environment) a modulescript it will execute it and return its result, each subsquent require will return the same result, as require caches it.
If we want to store and retrieve something from a modulescript we make it return a table. Because a table is pass by reference, with that I mean, it returns a reference to the object.
If we didnt and used an string, which is pass by value.
Example string:
modulescript
return "Hello"
require from script 1
local module = require(modulescript)
print(module)
module = "not hello"
print(module)
require from script 2
wait(5)
local module = require(modulescript)
print(module)
Actually in script 1 we only changed variable module to hold 'not hello'
Example table
modulescript
return {message = "Hello"}
require from script 1
local module = require(modulescript)
print(module.message)
module.message = "not hello"
print(module.message)
require from script 2
wait(5)
local module = require(modulescript)
print(module)
so even though the modulescript only fires once, we make changes to table it returns and those changes we can see from other scripts. Because the modulescript each time returns the reference to the table.
In your example it would be like this
modulescript
local module = {}
module.Value = 5
return module
your localscript
local player = game.Players.LocalPlayer
local MODE = script.Parent.Parent.Parent.MODE
local ItemName = script.Parent.Parent.Itemname
local Space = script.Parent.Parent.Space
local sellPrices = require(game.ReplicatedStorage.Sellprices)
local player = game.Players.LocalPlayer
local cash = player.leaderstats.Cash
MODE.Changed:Connect(function()
if MODE.Value == false then
script.Parent.Parent.BUTTON.Text = "Sell"
elseif
MODE.Value == true then
script.Parent.Parent.BUTTON.Text = "Put"
end
end)
script.Parent.MouseButton1Click:Connect(function()
print("s")
if MODE.Value == false then
Space.Value = false
ItemName.Value = ""
cash.Value += sellPrices.Value
end
end)