LoadCharacter() not working right after enabling R15

  1. What do you want to achieve?
    I would like to be able to call LoadCharacter() and have the player return to the same position they were at before calling this function.

  2. What is the issue?
    After enabling R15 on my game (it was initially only set to R6), this script has broken and isn’t working correctly. Nothing after calling LoadCharacter() runs, including the code that returns the player back to the position they were at earlier. The print statement after this function won’t print either.

  3. What solutions have you tried so far?
    Tried adding waits and doing research on this but I am not seeing any reason why this is happening since it was working fine before enabling R15 support.

Here is the code for the script I am using. For context, this is inside of a GUI button that a player would press.

local plr = script.Parent.Parent.Parent.Parent

script.Parent.MouseButton1Click:Connect(function()
	local a = plr.Character:WaitForChild("HumanoidRootPart").CFrame
	print(a)
	plr:LoadCharacter(true) --Anything beyond this function doesn't run, but the player still respawns 
	plr.Character:WaitForChild("HumanoidRootPart").CFrame = a
	print(plr.Character:WaitForChild("HumanoidRootPart").CFrame)
	print("This isn't printing!")
end)

Is this supposed to be intentional? And if so, how can I return the player to their previous position using their Cframe?

Edit: Just to clarify, the goal of this script is to refresh the player without having them return to the spawn. When calling this function they were able to respawn and then be teleported back to their previous position, but now it just respawns them and leaves them at the spawn.

This is because you are still referencing the old character when you are finished respawning, LoadCharacter creates a new one

I think I figured it out. I disabled the “ResetOnSpawn” property on the GUI this button was in and it fixed it. I’m guessing when it was pressed, it reset everything inside of the GUI so the rest of the script wouldn’t run because it was being reset. I think I originally had this disabled and must have accidentally changed it today. Thanks for the help anyway!