Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Calling a module more multiple times?

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

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.