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 7 years ago
01local gold = {}
02 
03playerData = {}
04 
05local dataStoreService = game:GetService("DataStoreService")
06local playerDataStore = dataStoreService:GetDataStore("PlayerDataStoreTest3")
07 
08function gold.awardGold(player, goldGiven)
09    if player and goldGiven then
10        local myData = playerDataStore:GetAsync(player.userId) or {}
11        playerData[player.userId] = myData 
12        if myData then
13            myData.gold = myData.gold + goldGiven
14            local goldValue = player.PlayerFolder:WaitForChild("Gold")
15            if goldValue then
View all 22 lines...

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
7 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.

1local module = require(module)
2 
3module.awardGold(plr, 10)
4module.awardGold(plr, 10)
Ad

Answer this question