ChangeHistoryService crashes studio

I am making a plugin that uses ChangeHistoryService and when I call :Undo() or :Redo() the service crashes the studio, is there a way around this crash?

Maybe you’re calling it when there’s not history to revert back to?

I used CanGetRedo() or CanGetUndo() to check, there were histories

I used CanGetRedo() or CanGetUndo() to check, there were histories[/quote]

What is the code you’re using? Does it happen if you just call :Undo()/:Redo() without your other code?

I will post again when I test this out

I used CanGetRedo() or CanGetUndo() to check, there were histories[/quote]

What is the code you’re using? Does it happen if you just call :Undo()/:Redo() without your other code?[/quote]

It works without my other code but through all my efforts I cannot understand why, do I need to set a waypoint right after activating the service?

Is there any reason it would crash?

Post your code… Only then we can help you out… We won’t steal anything, we are help to help you…

Okay so I have basically isolated the event between two pieces of code, one piece crashes the server, the next allows ChangeHistoryService to work, the problem is I do not understand what the difference between the two is, and I need to know the difference so I do not keep crashing my studio; These are both Plugin scripts.

Working code:

Button.Click:connect(function()
	print(123)
	count=count+1
	if ChangeHistoryService:GetCanUndo()then
		ChangeHistoryService:Undo();
		ChangeHistoryService:SetWaypoint('Hello')
	end	
--	Mouse=Plugin:GetMouse()
--	print(Mouse)
--	Mouse.KeyDown:connect(function(k)
--		print(k)
--		if k=="t"then
--			if ChangeHistoryService:GetCanUndo()then
--				ChangeHistoryService:Undo();
--				ChangeHistoryService:SetWaypoint('Hello')
--			end			
--		end
--	end)
end)

Crash Code:

Button.Click:connect(function()
	print(123)
	count=count+1
--	if ChangeHistoryService:GetCanUndo()then
--		ChangeHistoryService:Undo();
--		ChangeHistoryService:SetWaypoint('Hello')
--	end	
	Mouse=Plugin:GetMouse()
	print(Mouse)
	Mouse.KeyDown:connect(function(k)
		print(k)
		if k=="t"then
			if ChangeHistoryService:GetCanUndo()then
				ChangeHistoryService:Undo();
				ChangeHistoryService:SetWaypoint('Hello')
			end			
		end
	end)
end)

NOTE: (I Removed the Plugin:Activate(true) from both snippets because in neither case does it affect ChangeHistoryService)

So why is the first snipper working compared to the other snippet?

posted before I saw this, I guess I can read minds now… huh.

I have been doing more testing and it seems like the “Undo()” and “Redo()” only work when ran on the Click Event of the Button. I have tried RbxUtility signals, coroutines, Spawn, debounce calls, but as far As i could tell it only works in the Click event…

I have no other plugins installed or active that interact with ChangeHistoryService