Am I able to add a second event to a function?

  1. What do you want to achieve? I want to add a second event to a function

  2. What is the issue? I’m not sure if I can or how

  3. What solutions have you tried so far? I looked online

-- 

game.Players.PlayerAdded:Connect(function(player)
	local cashdatastore  = ds2("cashv1",player)
	local leveldatastore  = ds2("levelv1",player)
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	local cash = Instance.new("IntValue")
	local level = Instance.new("IntValue")
	
	cash.Value =  0
	cash.Name = "Cash"
	
	level.Value =  0
	level.Name = "Level"
	
	level.Parent = leaderstats
	cash.Parent = leaderstats
	leaderstats.Parent = player
	
	
	local function updatedata(updatedvalue)
		cash.Value = cashdatastore:Get(updatedvalue)
		level.Value = leveldatastore:Get(updatedvalue)
	end
	updatedata()
	
	cashdatastore:OnUpdate(updatedata()) 
	
end)


cashdatastore:OnUpdate(updatedata) 

Then call it in the cashdatastore:OnUpdate function.

I mean, am I able to do this along side the other event?

leveldatastore:OnUpdate(updatedata())

No I don’t think you can do that.

Not related to your problem, but GlobalDatastore:OnUpdate doesn’t exist in the official documentation…