Datastore2's OnUpdate function isnt working for me?

Hello, I have the same issue like this where it doesn’t update but only works when I just rejoin but I don’t have the () on mine. I have like a slot system. Heres how it works:

Default Values:

local defaultEquippedSlots = {	GearSlot1 = "";	GearSlot2 = "";	GearSlot3 = "";	PerkSlot = ""; } 

Table of DataStores

local slotsStore = {	GearSlot1 = DataStore2("GearSlot1", player),	GearSlot2 = DataStore2("GearSlot2", player),	GearSlot3 = DataStore2("GearSlot3", player),	PerkSlot = DataStore2("PerkSlot", player),	} 

The function (They store string values) (They all use this same function):

local function updateEquippedSlots(newString, slot)	if slot then	print(slot.Value)	print(slot.Name)	print(newString)	slot.Value = newString	print("yes")	end end 

Here is where the OnUpdate takes place. I’m not too sure why it doesn’t update when in-game whenever I try to change the value. (As you can see I try my best to shorten code as much as possible)

for key, stringValue in pairs(slotsStore) do	updateEquippedSlots(stringValue:Get(defaultEquippedSlots[key]), player.Slots:FindFirstChild(key))	stringValue:OnUpdate(updateEquippedSlots)	end 

Sorry for bumping this old topic, I just didn’t feel to make a new one since this one is extremely similar to mine. I just have something a little different. If anyone needs more code parts let me know!

1 Like