local DataStore2 = require(1936396537)

local OriginalCookie = 0

game:GetService("Players").PlayerAdded:Connect(function(player)
	
	OriginalCookie = DataStore2("original",player)
	
	local original = Instance.new("NumberValue")
	original.Parent = game:GetService("ServerScriptService")
	
	local function originalUpdate(updateValue)
		original = OriginalCookie:Get(updateValue)
		print(OriginalCookie)
	end

	originalUpdate(0) -- making sure it is set to 0 if you have no datastore
	
	OriginalCookie:OnUpdate(originalUpdate)

	if OriginalCookie == 1 then
		game.ReplicatedStorage.OriginalEvent:FireClient(player)
		CookieCount = CookieCount+1
	end

end)

Now, if OriginalCookie is 1 it is supposed to fire an event, and it isn't firing, even though OriginalCookie is 1 when I close out. There is a print that prints OriginalCookie to see if it just isn't saving, but it prints table: 0x266b4d7b39fc347d, and not 0 or 1. Can anybody explain this?

5 comments

0

Original cookie is a table. Cause that’s what it does for me when I do that. Is “original” a table in the datastore inside player? I don’t know much about Datastore two but that’s the case.

0

How do i make original cookie just a variable then?

0

And no, "original" is a NumberValue created by Instance.New, parented to ServerScriptService

0

You missed something. To assign the value to NumberValue(or any kind of value storing object), do NumberValue.Value . And OriginalCookie is the data store you get from DataStore2().

0

And OriginalCookie is a table(base on what the output said) so when you compare a table to a number it would be false and the if-then statement will skip the code.