AutoLoadCharacter replacing morph after player fully spawns

For the game I am making, I am trying to achieve something where when the player dies during a round, they morph into a character once they respawn again, but when they spawn in and my script morphs them into the character, seconds later they will just spawn in their default character with the invincibility bubble completely reversing the morph I just made. I have tried turning AutoLoadCharacter off, but that just caused a bunch of bugs that made GUI go haywire that I had trouble solving.

Current Script:

local remote = game.ReplicatedStorage.RemoteEvents.ChangeChar

local function changeChar(player, character)
	
	while not player.Character or not player.Character.Parent do
		player.CharacterAdded:Wait()
	end
	
	print(player)
	print(character)
	print("changing character")

	local model = game.ReplicatedStorage.Misc.DrakobloxxerMorph
	local oldCharacter = player.Character
	local newCharacter = model.Drakobloxxer:Clone()

	newCharacter.HumanoidRootPart.Anchored = false
	newCharacter:SetPrimaryPartCFrame(oldCharacter.PrimaryPart.CFrame)

	player.Character = newCharacter
	newCharacter.Parent = workspace
end


remote.OnServerEvent:Connect(function(player, character)
	if _G.RoundBeingPlayed == true then
		wait(0.1)
		
		print("about to change")
		if player:WaitForChild("humanBool").Value == true then
			print("its still true")
		end
		
		repeat
			task.wait()
		until player:WaitForChild("humanBool").Value == false
		
		if player:WaitForChild("humanBool").Value == false then
			wait(0.25)
			changeChar(player, character)
			print("changed char")
		end
	end
end)

After Morph Finishes:

image

Once character auto spawns in seconds later:

image

1 Like