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

Calling a module more multiple times?

Asked by 6 years ago
local gold = {}

playerData = {}

local dataStoreService = game:GetService("DataStoreService")
local playerDataStore = dataStoreService:GetDataStore("PlayerDataStoreTest3")

function gold.awardGold(player, goldGiven)
    if player and goldGiven then
        local myData = playerDataStore:GetAsync(player.userId) or {}
        playerData[player.userId] = myData  
        if myData then
            myData.gold = myData.gold + goldGiven
            local goldValue = player.PlayerFolder:WaitForChild("Gold")
            if goldValue then
                goldValue.Value = myData.gold
            end
        end
    end 
end

return gold

Here I have my module which gives gold to players, and it works, but I cant call it again. How do I call it multiple times?

1 answer

Log in to vote
1
Answered by
Pejorem 164
6 years ago

Why would you need to call it multiple times? You only need to require a module once in one script? If required again it would be in another script, unless you were wanting to refresh some form of information in the processing of your code.

local module = require(module)

module.awardGold(plr, 10)
module.awardGold(plr, 10)
Ad

Answer this question