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

[SOLVED] How do you use the DataStore2 module?

I'm trying to learn how to use the module DataStore2 and i can't find out why this error keeps happening.

local DataStore2 require(1936396537) local limit = 25

local DataStore2 require(1936396537)
local limit = 25

local DefaultStrength = 0

game.Players.PlayerAdded:Connect(function(player)
	local Strength = player:WaitForChild("invisstats").Strength.Value
	local StrengthStore = DataStore2("Strength",player)
	
	local function UpdateStrength(Strength)
		if Strength >= limit then
			Strength:Increment(limit(StrengthStore:Get(DefaultStrength) ) * -1)
		else
			player.invisstats = Strength
		end
	end
	UpdateStrength(StrengthStore:Get(DefaultStrength))
	
	StrengthStore:OnUpdate(UpdateStrength)
end)

On line 8 the error:

ServerScriptService.Data Stores:8: attempt to call a nil value

keeps appearing when i run the code, i have no idea why.

1 answer

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