Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to edit a value in a module script?

Asked by 4 years ago

So basically I made a Developer product when you buy it, it would edit a value in a module script. I've made a function inside a script that changes the value in a module script. Here's the function.

function VIPBenefits(Player)
    for i,v in pairs(Player:WaitForChild("Backpack"):GetChildren()) do
        if v:IsA("Tool") then
            require(v:WaitForChild("Configuration")).Spaces = "Infinite"
        end
    end

    Player:WaitForChild("Backpack").ChildAdded:Connect(function(Tool)
        require(Tool:WaitForChild("Configuration")).Spaces = "Infinite"
    end)

end

It doesn't give me any errors at all but it still didn't change the value in a module script and yes the function runs when the player buys the dev product. I already tested it out by buying the product in studio so I wont waste any robux just for testing if it worked

1 answer

Log in to vote
1
Answered by
Nckripted 580 Moderation Voter
4 years ago

So first of all, make sure you have these lines in your module script (I will be using values as an example):

local values = {} --Important

--Add your code here:
values.Money = 0

return values --Important

Remember that a value has to be defined like this (you probably did this):

varName.Value = value

You would get the value like this:

local whereverYouPutTheModule = game:GetService("WhereverYouPutTheModule")
local values = require(whereverYouPutTheModule:WaitForChild("Values")

print(values.Money)

I personally think that you should use the requires as a variable. This might be the answer if you did everything above.

However, it might be an error with the way you are checking module.Spaces in your script. It would help if you told us how you are using it.

0
Thanks! This somehow made it work! DizzyGuy70 38 — 4y
Ad

Answer this question