How to detect if number changed in a module script

Hi, title says it all so here’s the current code I tried, which obviously failed as I am here:
(fyi if v.Completed == v.Goal then works fine when outside the scope of :Changed()

v.Completed.Changed:Connect(function()
			
			NewTask.Completion.Text = tostring(v.Completed .. " / " .. v.Goal)
			
			if v.Completed == v.Goal then
				NewTask.Completion.Text = "COMPLETED"
				NewTask.Completion.TextColor3 = Color3.fromRGB(0, 255, 0)
				NewTask.Description.TextColor3 = Color3.fromRGB(0, 255, 0)
				NewTask.Checkbox.Image = "rbxassetid://71596434996966"
				NewTask.Checkbox.ImageColor3 = Color3.fromRGB(0, 255, 0)
			end
		end)

And here’s a snippet of the module:

		["Mission"] = {
			["Clean"] = {
				FrameName = "Clean",
				Description = "Clean fighter fuselages",
				Completed = 0,
				Goal = 3},
			["Fuel"] = {
				FrameName = "Fuel",
				Description = "Connect cryogenic fuel pumps",
				Completed = 0,
				Goal = 3},
			["Ladders"] = {
				FrameName = "Ladders",
				Description = "Attach ladders to X-Wings",
				Completed = 0,
				Goal = 3}}}}

Are you talking about the completed number variable in your table?

Yeah, I want it to detect when the number in Completed = # has changed

To be honest you’d probably have to repeatedly check the number and see if there’s a change then fire a remote or bindable event indicating that the number has changed

OR

When your code changes the value just fire an event

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.